@@ 10-42 (lines=33) @@ | ||
7 | use Taisiya\CoreBundle\Console\Command\Cache\RebuildInternalCacheCommand; |
|
8 | use Taisiya\CoreBundle\Event\Composer\CommandEvent; |
|
9 | ||
10 | class RebuildInternalCacheSubscriber implements EventSubscriberInterface |
|
11 | { |
|
12 | /** |
|
13 | * {@inheritdoc} |
|
14 | */ |
|
15 | public static function getSubscribedEvents() |
|
16 | { |
|
17 | return [ |
|
18 | CommandEvent::NAME => [ |
|
19 | ['rebuildInternalCache', -1000], |
|
20 | ], |
|
21 | ]; |
|
22 | } |
|
23 | ||
24 | /** |
|
25 | * @param CommandEvent $event |
|
26 | */ |
|
27 | public function rebuildInternalCache(CommandEvent $event): void |
|
28 | { |
|
29 | /** @var ConsoleOutput $output */ |
|
30 | $output = $event->getApp()->getContainer()['console.output']; |
|
31 | ||
32 | if ($output->isVerbose()) { |
|
33 | $str = 'Run '.RebuildInternalCacheCommand::NAME.' command'; |
|
34 | $output->writeln(''); |
|
35 | $output->writeln($str); |
|
36 | $output->writeln(str_repeat('-', strlen($str))); |
|
37 | } |
|
38 | ||
39 | $input = new ArrayInput([RebuildInternalCacheCommand::NAME]); |
|
40 | $event->getApp()->getConsole()->doRun($input, $output); |
|
41 | } |
|
42 | } |
|
43 |
@@ 10-42 (lines=33) @@ | ||
7 | use Taisiya\CoreBundle\Console\Command\Config\RebuildSettingsCommand; |
|
8 | use Taisiya\CoreBundle\Event\Composer\CommandEvent; |
|
9 | ||
10 | class RebuildSettingsSubscriber implements EventSubscriberInterface |
|
11 | { |
|
12 | /** |
|
13 | * {@inheritdoc} |
|
14 | */ |
|
15 | public static function getSubscribedEvents() |
|
16 | { |
|
17 | return [ |
|
18 | CommandEvent::NAME => [ |
|
19 | ['rebuildSettings', -900], |
|
20 | ], |
|
21 | ]; |
|
22 | } |
|
23 | ||
24 | /** |
|
25 | * @param CommandEvent $event |
|
26 | */ |
|
27 | public function rebuildSettings(CommandEvent $event): void |
|
28 | { |
|
29 | /** @var OutputFormatter $output */ |
|
30 | $output = $event->getApp()->getContainer()['console.output']; |
|
31 | ||
32 | if ($output->isVerbose()) { |
|
33 | $str = 'Run '.RebuildSettingsCommand::NAME.' command'; |
|
34 | $output->writeln(''); |
|
35 | $output->writeln($str); |
|
36 | $output->writeln(str_repeat('-', strlen($str))); |
|
37 | } |
|
38 | ||
39 | $input = new ArrayInput([RebuildSettingsCommand::NAME]); |
|
40 | $event->getApp()->getConsole()->doRun($input, $output); |
|
41 | } |
|
42 | } |
|
43 |