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 = 'page_id';
20 
26  protected $_previewFlag;
27 
33  protected $_eventPrefix = 'cms_page_collection';
34 
40  protected $_eventObject = 'page_collection';
41 
47  protected function _construct()
48  {
49  $this->_init(\Magento\Cms\Model\Page::class, \Magento\Cms\Model\ResourceModel\Page::class);
50  $this->_map['fields']['page_id'] = 'main_table.page_id';
51  $this->_map['fields']['store'] = 'store_table.store_id';
52  }
53 
60  public function setFirstStoreFlag($flag = false)
61  {
62  $this->_previewFlag = $flag;
63  return $this;
64  }
65 
73  public function addStoreFilter($store, $withAdmin = true)
74  {
75  if (!$this->getFlag('store_filter_added')) {
76  $this->performAddStoreFilter($store, $withAdmin);
77  }
78  return $this;
79  }
80 
86  protected function _afterLoad()
87  {
88  $entityMetadata = $this->metadataPool->getMetadata(PageInterface::class);
89  $this->performAfterLoad('cms_page_store', $entityMetadata->getLinkField());
90  $this->_previewFlag = false;
91 
92  return parent::_afterLoad();
93  }
94 
100  protected function _renderFiltersBefore()
101  {
102  $entityMetadata = $this->metadataPool->getMetadata(PageInterface::class);
103  $this->joinStoreRelationTable('cms_page_store', $entityMetadata->getLinkField());
104  }
105 }