Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
UrlRewriteCollection.php
Go to the documentation of this file.
1 <?php
9 
11 {
17  protected $storeManager;
18 
28  public function __construct(
29  \Magento\Framework\Data\Collection\EntityFactoryInterface $entityFactory,
30  \Psr\Log\LoggerInterface $logger,
31  \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy,
32  \Magento\Framework\Event\ManagerInterface $eventManager,
33  \Magento\Store\Model\StoreManagerInterface $storeManager,
34  \Magento\Framework\DB\Adapter\AdapterInterface $connection = null,
35  \Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource = null
36  ) {
37  parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $connection, $resource);
38  $this->storeManager = $storeManager;
39  }
40 
46  protected function _construct()
47  {
48  $this->_init(
49  \Magento\UrlRewrite\Model\UrlRewrite::class,
50  \Magento\UrlRewrite\Model\ResourceModel\UrlRewrite::class
51  );
52  }
53 
62  public function addStoreFilter($store, $withAdmin = true)
63  {
64  if (!is_array($store)) {
65  $store = [$this->storeManager->getStore($store)->getId()];
66  }
67  if ($withAdmin) {
68  $store[] = 0;
69  }
70 
71  $this->addFieldToFilter('store_id', ['in' => $store]);
72 
73  return $this;
74  }
75 }
$resource
Definition: bulk.php:12
$logger
$connection
Definition: bulk.php:13
__construct(\Magento\Framework\Data\Collection\EntityFactoryInterface $entityFactory, \Psr\Log\LoggerInterface $logger, \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy, \Magento\Framework\Event\ManagerInterface $eventManager, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\DB\Adapter\AdapterInterface $connection=null, \Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource=null)