More tidying.
[yaffs-website] / vendor / drupal / console / src / Command / Cache / ContextDebugCommand.php
1 <?php
2
3 /**
4  * @file
5  * Contains \Drupal\Console\Command\Cache\ContextDebugCommand.
6  */
7
8 namespace Drupal\Console\Command\Cache;
9
10 use Symfony\Component\Console\Input\InputInterface;
11 use Symfony\Component\Console\Output\OutputInterface;
12 use Symfony\Component\Console\Command\Command;
13 use Drupal\Console\Core\Command\Shared\ContainerAwareCommandTrait;
14 use Drupal\Console\Core\Style\DrupalStyle;
15
16 /**
17  * Class ContextDebugCommand.
18  *
19  * @package Drupal\Console\Command\Cache
20  */
21 class ContextDebugCommand extends Command
22 {
23     use ContainerAwareCommandTrait;
24
25     /**
26      * {@inheritdoc}
27      */
28     protected function configure()
29     {
30         $this
31             ->setName('cache:context:debug')
32             ->setDescription($this->trans('commands.cache.context.debug.description'));
33     }
34
35     /**
36      * {@inheritdoc}
37      */
38     protected function execute(InputInterface $input, OutputInterface $output)
39     {
40         $io = new DrupalStyle($input, $output);
41         $contextManager = $this->get('cache_contexts_manager');
42
43         $tableHeader = [
44             $this->trans('commands.cache.context.debug.messages.code'),
45             $this->trans('commands.cache.context.debug.messages.label'),
46             $this->trans('commands.cache.context.debug.messages.class'),
47         ];
48
49         $tableRows = [];
50
51         foreach ($contextManager->getAll() as $code) {
52             $context = $this->get('cache_context.'.$code);
53             $tableRows[] = [
54                 $code,
55                 $context->getLabel()->render(),
56                 get_class($context),
57             ];
58         }
59
60         $io->table($tableHeader, $tableRows, 'compact');
61
62         return 0;
63     }
64 }