@@ 21-65 (lines=45) @@ | ||
18 | /** |
|
19 | * This command removes warmers from elasticsearch index. |
|
20 | */ |
|
21 | class WarmerDeleteCommand extends AbstractManagerAwareCommand |
|
22 | { |
|
23 | /** |
|
24 | * {@inheritdoc} |
|
25 | */ |
|
26 | protected function configure() |
|
27 | { |
|
28 | parent::configure(); |
|
29 | ||
30 | $this |
|
31 | ->setName('ongr:es:warmer:delete') |
|
32 | ->setDescription('Removes warmers from elasticsearch index.') |
|
33 | ->addArgument( |
|
34 | 'names', |
|
35 | InputArgument::IS_ARRAY | InputArgument::OPTIONAL, |
|
36 | 'Warmer names', |
|
37 | [] |
|
38 | ); |
|
39 | } |
|
40 | ||
41 | /** |
|
42 | * {@inheritdoc} |
|
43 | */ |
|
44 | protected function execute(InputInterface $input, OutputInterface $output) |
|
45 | { |
|
46 | $names = $input->getArgument('names'); |
|
47 | $status = $this->getManager($input->getOption('manager'))->getConnection()->deleteWarmers($names); |
|
48 | ||
49 | if ($status === false) { |
|
50 | $message = '<info>There are no warmers registered for manager named<info> <comment>`%s`</comment>!'; |
|
51 | } elseif (empty($names)) { |
|
52 | $message = '<info>All warmers have been deleted from manager named<info> <comment>`%s`</comment>'; |
|
53 | } else { |
|
54 | $callback = function ($val) { |
|
55 | return '`' . $val . '`'; |
|
56 | }; |
|
57 | $message = '<comment>' . implode(', ', array_map($callback, $names)) . '</comment>' |
|
58 | . '<info> warmer(s) have been deleted from manager named</info> <comment>`%s`</comment>'; |
|
59 | } |
|
60 | ||
61 | $output->writeln(sprintf($message, $input->getOption('manager'))); |
|
62 | ||
63 | return 0; |
|
64 | } |
|
65 | } |
|
66 |
@@ 21-65 (lines=45) @@ | ||
18 | /** |
|
19 | * This command puts warmers into elasticsearch index. |
|
20 | */ |
|
21 | class WarmerPutCommand extends AbstractManagerAwareCommand |
|
22 | { |
|
23 | /** |
|
24 | * {@inheritdoc} |
|
25 | */ |
|
26 | protected function configure() |
|
27 | { |
|
28 | parent::configure(); |
|
29 | ||
30 | $this |
|
31 | ->setName('ongr:es:warmer:put') |
|
32 | ->setDescription('Puts warmers into elasticsearch index.') |
|
33 | ->addArgument( |
|
34 | 'names', |
|
35 | InputArgument::IS_ARRAY | InputArgument::OPTIONAL, |
|
36 | 'Warmers names.', |
|
37 | [] |
|
38 | ); |
|
39 | } |
|
40 | ||
41 | /** |
|
42 | * {@inheritdoc} |
|
43 | */ |
|
44 | protected function execute(InputInterface $input, OutputInterface $output) |
|
45 | { |
|
46 | $names = $input->getArgument('names'); |
|
47 | $status = $this->getManager($input->getOption('manager'))->getConnection()->putWarmers($names); |
|
48 | ||
49 | if ($status === false) { |
|
50 | $message = '<info>There are no warmers registered for manager named<info> <comment>`%s`</comment>!'; |
|
51 | } elseif (empty($names)) { |
|
52 | $message = '<info>All warmers have been put into manager named<info> <comment>`%s`</comment>'; |
|
53 | } else { |
|
54 | $callback = function ($val) { |
|
55 | return '`' . $val . '`'; |
|
56 | }; |
|
57 | $message = '<comment>' . implode(', ', array_map($callback, $names)) . '</comment>' |
|
58 | . '<info> warmer(s) have been put into manager named</info> <comment>`%s`</comment>'; |
|
59 | } |
|
60 | ||
61 | $output->writeln(sprintf($message, $input->getOption('manager'))); |
|
62 | ||
63 | return 0; |
|
64 | } |
|
65 | } |
|
66 |