Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
DependencyInfoProvider.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
9 
13 
18 {
22  private $config;
23 
27  public function __construct(ConfigInterface $config)
28  {
29  $this->config = $config;
30  }
31 
35  public function getIndexerIdsToRunBefore(string $indexerId): array
36  {
37  return $this->getIndexerDataWithValidation($indexerId)['dependencies'];
38  }
39 
43  public function getIndexerIdsToRunAfter(string $indexerId): array
44  {
46  $this->getIndexerDataWithValidation($indexerId);
47  $result = [];
48  foreach ($this->config->getIndexers() as $id => $indexerData) {
49  if (array_search($indexerId, $indexerData['dependencies']) !== false) {
50  $result[] = $id;
51  }
52  };
53 
54  return $result;
55  }
56 
63  private function getIndexerData(string $indexerId): array
64  {
65  return $this->config->getIndexer($indexerId);
66  }
67 
75  private function getIndexerDataWithValidation(string $indexerId): array
76  {
77  $indexerData = $this->getIndexerData($indexerId);
78  if (!isset($indexerData['indexer_id']) || $indexerData['indexer_id'] != $indexerId) {
79  throw new NoSuchEntityException(
80  new Phrase("%1 indexer does not exist.", [$indexerId])
81  );
82  }
83 
84  return $indexerData;
85  }
86 }
$config
Definition: fraud_order.php:17
$id
Definition: fieldset.phtml:14