These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Kunstmaan\SearchBundle\Command; |
||
4 | |||
5 | use Kunstmaan\SearchBundle\Configuration\SearchConfigurationChain; |
||
6 | use Kunstmaan\SearchBundle\Configuration\SearchConfigurationInterface; |
||
7 | use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; |
||
8 | use Symfony\Component\Console\Input\InputInterface; |
||
9 | use Symfony\Component\Console\Output\OutputInterface; |
||
10 | |||
11 | /** |
||
12 | * Command to delete all indexes. |
||
13 | * |
||
14 | * It will load the SearchConfigurationChain and call the deleteIndex() method on each SearchConfiguration |
||
15 | * |
||
16 | * @final since 5.1 |
||
17 | * NEXT_MAJOR extend from `Command` and remove `$this->getContainer` usages |
||
18 | */ |
||
19 | View Code Duplication | class DeleteIndexCommand extends ContainerAwareCommand |
|
0 ignored issues
–
show
|
|||
20 | { |
||
21 | /** |
||
22 | * @var SearchConfigurationChain |
||
23 | */ |
||
24 | private $configurationChain; |
||
25 | |||
26 | public function __construct(/* SearchConfigurationChain */ $configurationChain = null) |
||
27 | { |
||
28 | parent::__construct(); |
||
29 | |||
30 | if (!$configurationChain instanceof SearchConfigurationChain) { |
||
31 | @trigger_error(sprintf('Passing a command name as the first argument of "%s" is deprecated since version symfony 3.4 and will be removed in symfony 4.0. If the command was registered by convention, make it a service instead. ', __METHOD__), E_USER_DEPRECATED); |
||
32 | |||
33 | $this->setName(null === $configurationChain ? 'kuma:search:delete' : $configurationChain); |
||
34 | |||
35 | return; |
||
36 | } |
||
37 | |||
38 | $this->configurationChain = $configurationChain; |
||
39 | } |
||
40 | |||
41 | protected function configure() |
||
42 | { |
||
43 | $this |
||
44 | ->setName('kuma:search:delete') |
||
45 | ->setDescription('Delete the index(es)'); |
||
46 | } |
||
47 | |||
48 | /** |
||
49 | * @param InputInterface $input |
||
50 | * @param OutputInterface $output |
||
51 | * |
||
52 | * @return null|int null or 0 if everything went fine, or an error code |
||
53 | */ |
||
54 | protected function execute(InputInterface $input, OutputInterface $output) |
||
55 | { |
||
56 | if (null === $this->configurationChain) { |
||
57 | $this->configurationChain = $this->getContainer()->get('kunstmaan_search.search_configuration_chain'); |
||
58 | } |
||
59 | /** |
||
60 | * @var string |
||
61 | * @var SearchConfigurationInterface $searchConfiguration |
||
62 | */ |
||
63 | foreach ($this->configurationChain->getConfigurations() as $alias => $searchConfiguration) { |
||
64 | $searchConfiguration->deleteIndex(); |
||
65 | $output->writeln('Index deleted : ' . $alias); |
||
66 | } |
||
67 | |||
68 | return 0; |
||
69 | } |
||
70 | } |
||
71 |
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.