Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AbstractFlatState.php
Go to the documentation of this file.
1 <?php
7 
9 
14 abstract class AbstractFlatState
15 {
19  const INDEXER_ID = '';
20 
25 
29  protected $scopeConfig;
30 
34  protected $isAvailable;
35 
39  protected $indexerRegistry;
40 
46  public function __construct(
48  \Magento\Framework\Indexer\IndexerRegistry $indexerRegistry,
49  $isAvailable = false
50  ) {
51  $this->scopeConfig = $scopeConfig;
52  $this->indexerRegistry = $indexerRegistry;
53  $this->isAvailable = $isAvailable;
54  }
55 
61  public function isFlatEnabled()
62  {
63  return $this->scopeConfig->isSetFlag(static::INDEXER_ENABLED_XML_PATH, ScopeInterface::SCOPE_STORE);
64  }
65 
71  public function isAvailable()
72  {
73  return $this->isAvailable && $this->isFlatEnabled()
74  && $this->indexerRegistry->get(static::INDEXER_ID)->isValid();
75  }
76 }
__construct(\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\Indexer\IndexerRegistry $indexerRegistry, $isAvailable=false)