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