1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @copyright Copyright (c) 1999-2017 netz98 GmbH (http://www.netz98.de) |
4
|
|
|
* |
5
|
|
|
* @see PROJECT_LICENSE.txt |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
namespace N98\Magento\Command\Indexer; |
9
|
|
|
|
10
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
11
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
12
|
|
|
|
13
|
|
|
class RecreateTriggersCommand extends AbstractIndexerCommand |
14
|
|
|
{ |
15
|
|
|
/** |
16
|
|
|
* @var \Magento\Indexer\Model\Config |
17
|
|
|
*/ |
18
|
|
|
private $indexerCollection; |
19
|
|
|
|
20
|
|
|
protected function configure() |
21
|
|
|
{ |
22
|
|
|
$this |
23
|
|
|
->setName('index:trigger:recreate') |
24
|
|
|
->setDescription('ReCreate all triggers') |
25
|
|
|
; |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @param \Magento\Indexer\Model\Config $indexerCollection |
|
|
|
|
30
|
|
|
*/ |
31
|
|
|
public function inject(\Magento\Indexer\Model\Indexer\Collection $indexerCollection) |
32
|
|
|
{ |
33
|
|
|
$this->indexerCollection = $indexerCollection; |
|
|
|
|
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @param \Symfony\Component\Console\Input\InputInterface $input |
38
|
|
|
* @param \Symfony\Component\Console\Output\OutputInterface $output |
39
|
|
|
* @return int|void |
40
|
|
|
*/ |
41
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
42
|
|
|
{ |
43
|
|
|
$this->detectMagento($output, true); |
44
|
|
|
|
45
|
|
|
if (!$this->initMagento()) { |
46
|
|
|
return; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
foreach ($this->getIndexerCollection() as $indexer) { |
50
|
|
|
/** @var $indexer \Magento\Framework\Indexer\IndexerInterface */ |
51
|
|
|
if ($indexer->isScheduled()) { |
52
|
|
|
$indexer->getView()->unsubscribe(); |
53
|
|
|
$indexer->getView()->subscribe(); |
54
|
|
|
$output->writeln( |
55
|
|
|
sprintf('Re-created triggers of indexer <info>%s</info>', $indexer->getTitle()) |
56
|
|
|
); |
57
|
|
|
} else { |
58
|
|
|
$output->writeln( |
59
|
|
|
sprintf('Skipped indexer <info>%s</info>. Mode must be "schedule".', $indexer->getTitle()) |
60
|
|
|
); |
61
|
|
|
} |
62
|
|
|
} |
63
|
|
|
} |
64
|
|
|
} |
65
|
|
|
|
This check looks for
@param
annotations where the type inferred by our type inference engine differs from the declared type.It makes a suggestion as to what type it considers more descriptive.
Most often this is a case of a parameter that can be null in addition to its declared types.