Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Collection.php
Go to the documentation of this file.
1 <?php
7 
9 use \Magento\Cms\Model\ResourceModel\AbstractCollection;
10 
15 {
19  protected $_idFieldName = 'block_id';
20 
26  protected $_eventPrefix = 'cms_block_collection';
27 
33  protected $_eventObject = 'block_collection';
34 
40  protected function _afterLoad()
41  {
42  $entityMetadata = $this->metadataPool->getMetadata(BlockInterface::class);
43 
44  $this->performAfterLoad('cms_block_store', $entityMetadata->getLinkField());
45 
46  return parent::_afterLoad();
47  }
48 
54  protected function _construct()
55  {
56  $this->_init(\Magento\Cms\Model\Block::class, \Magento\Cms\Model\ResourceModel\Block::class);
57  $this->_map['fields']['store'] = 'store_table.store_id';
58  $this->_map['fields']['block_id'] = 'main_table.block_id';
59  }
60 
66  public function toOptionArray()
67  {
68  return $this->_toOptionArray('block_id', 'title');
69  }
70 
78  public function addStoreFilter($store, $withAdmin = true)
79  {
80  $this->performAddStoreFilter($store, $withAdmin);
81 
82  return $this;
83  }
84 
90  protected function _renderFiltersBefore()
91  {
92  $entityMetadata = $this->metadataPool->getMetadata(BlockInterface::class);
93  $this->joinStoreRelationTable('cms_block_store', $entityMetadata->getLinkField());
94  }
95 }
_toOptionArray($valueField=null, $labelField='name', $additional=[])
Definition: AbstractDb.php:641