Conditions | 9 |
Paths | 21 |
Total Lines | 26 |
Code Lines | 17 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
22 | protected function execute(InputInterface $input, OutputInterface $output) |
||
23 | { |
||
24 | $clients = []; |
||
25 | $ids = $this->getContainer()->getServiceIds(); |
||
26 | /** @var $ids array */ |
||
27 | foreach ($ids as $id) { |
||
28 | if (0 === strpos($id, 'snc_redis') && $this->getContainer()->get($id) instanceof Client) { |
||
29 | $clients[] = $id; |
||
30 | } |
||
31 | } |
||
32 | |||
33 | if (!empty($clients)) { |
||
34 | $allowed = $clients; |
||
35 | $clientsInput = $input->getArgument('clients'); |
||
36 | if (!empty($clientsInput)) { |
||
37 | /** @var $clientsInput array */ |
||
38 | foreach ($clientsInput as &$client) { |
||
39 | $client = 'snc_redis.'.$client; |
||
40 | } |
||
41 | unset($client); |
||
42 | $allowed = array_intersect($clients, $clientsInput); |
||
43 | } |
||
44 | foreach ($clients as $snc) { |
||
45 | if (\in_array($snc, $allowed, true)) { |
||
46 | $this->getContainer()->get($snc)->flushdb(); |
||
47 | $output->writeln('redis database '.$snc.' flushed'); |
||
48 | } |
||
53 |