Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
DependencyDecorator.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
9 
15 
22 {
26  private $indexer;
27 
31  private $dependencyInfoProvider;
32 
36  private $indexerRegistry;
37 
43  public function __construct(
44  IndexerInterface $indexer,
45  DependencyInfoProviderInterface $dependencyInfoProvider,
46  IndexerRegistry $indexerRegistry
47  ) {
48  $this->indexer = $indexer;
49  $this->dependencyInfoProvider = $dependencyInfoProvider;
50  $this->indexerRegistry = $indexerRegistry;
51  }
52 
56  public function __call(string $method, array $args)
57  {
58  return call_user_func_array([$this->indexer, $method], $args);
59  }
60 
64  public function __sleep()
65  {
66  return ['indexer', 'dependencyInfoProvider', 'indexerRegistry'];
67  }
68 
72  public function __clone()
73  {
74  $this->indexer = clone $this->indexer;
75  }
76 
80  public function getId(): string
81  {
82  return $this->indexer->getId();
83  }
84 
88  public function getViewId(): string
89  {
90  return $this->indexer->getViewId();
91  }
92 
96  public function getActionClass(): string
97  {
98  return $this->indexer->getActionClass();
99  }
100 
104  public function getTitle(): string
105  {
106  return $this->indexer->getTitle();
107  }
108 
112  public function getDescription(): string
113  {
114  return $this->indexer->getDescription();
115  }
116 
120  public function getFields(): array
121  {
122  return $this->indexer->getFields();
123  }
124 
128  public function getSources(): array
129  {
130  return $this->indexer->getSources();
131  }
132 
136  public function getHandlers(): array
137  {
138  return $this->indexer->getHandlers();
139  }
140 
144  public function load($indexerId): self
145  {
146  $this->indexer->load($indexerId);
147  return $this;
148  }
149 
153  public function getView(): ViewInterface
154  {
155  return $this->indexer->getView();
156  }
157 
161  public function getState(): StateInterface
162  {
163  return $this->indexer->getState();
164  }
165 
169  public function setState(StateInterface $state): self
170  {
171  $this->indexer->setState($state);
172  return $this;
173  }
174 
178  public function isScheduled(): bool
179  {
180  return $this->indexer->isScheduled();
181  }
182 
186  public function setScheduled($scheduled)
187  {
188  $this->indexer->setScheduled($scheduled);
189  }
190 
194  public function isValid(): bool
195  {
196  return $this->indexer->isValid();
197  }
198 
202  public function isInvalid(): bool
203  {
204  return $this->indexer->isInvalid();
205  }
206 
210  public function isWorking(): bool
211  {
212  return $this->indexer->isWorking();
213  }
214 
218  public function invalidate()
219  {
220  $this->indexer->invalidate();
221  $dependentIndexerIds = $this->dependencyInfoProvider->getIndexerIdsToRunAfter($this->indexer->getId());
222  foreach ($dependentIndexerIds as $indexerId) {
223  $this->indexerRegistry->get($indexerId)->invalidate();
224  }
225  }
226 
230  public function getStatus(): string
231  {
232  return $this->indexer->getStatus();
233  }
234 
238  public function getLatestUpdated(): string
239  {
240  return $this->indexer->getLatestUpdated();
241  }
242 
246  public function reindexAll()
247  {
248  $this->indexer->reindexAll();
249  }
250 
254  public function reindexRow($id)
255  {
256  $this->indexer->reindexRow($id);
257  $dependentIndexerIds = $this->dependencyInfoProvider->getIndexerIdsToRunAfter($this->indexer->getId());
258  foreach ($dependentIndexerIds as $indexerId) {
259  $dependentIndexer = $this->indexerRegistry->get($indexerId);
260  if (!$dependentIndexer->isScheduled()) {
261  $dependentIndexer->reindexRow($id);
262  }
263  }
264  }
265 
269  public function reindexList($ids)
270  {
271  $this->indexer->reindexList($ids);
272  $dependentIndexerIds = $this->dependencyInfoProvider->getIndexerIdsToRunAfter($this->indexer->getId());
273  foreach ($dependentIndexerIds as $indexerId) {
274  $dependentIndexer = $this->indexerRegistry->get($indexerId);
275  if (!$dependentIndexer->isScheduled()) {
276  $dependentIndexer->reindexList($ids);
277  }
278  }
279  }
280 }
$id
Definition: fieldset.phtml:14
__construct(IndexerInterface $indexer, DependencyInfoProviderInterface $dependencyInfoProvider, IndexerRegistry $indexerRegistry)
$method
Definition: info.phtml:13