Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
StateDependentCollectionFactory.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
8 
13 {
19  private $objectManager;
20 
26  private $catalogCategoryFlatState;
27 
34  public function __construct(
35  \Magento\Framework\ObjectManagerInterface $objectManager,
36  \Magento\Catalog\Model\Indexer\Category\Flat\State $catalogCategoryFlatState
37  ) {
38  $this->objectManager = $objectManager;
39  $this->catalogCategoryFlatState = $catalogCategoryFlatState;
40  }
41 
48  public function create(array $data = [])
49  {
50  return $this->objectManager->create(
51  ($this->catalogCategoryFlatState->isAvailable()) ? Flat\Collection::class : Collection::class,
52  $data
53  );
54  }
55 }
$objectManager
Definition: bootstrap.php:17
__construct(\Magento\Framework\ObjectManagerInterface $objectManager, \Magento\Catalog\Model\Indexer\Category\Flat\State $catalogCategoryFlatState)