4801c344e4f53e1b8759bfc4cfe4d3c0e69ed807
[yaffs-website] / vendor / drupal / console / src / Command / Debug / ImageStylesCommand.php
1 <?php
2
3 /**
4  * @file
5  * Contains \Drupal\Console\Command\Debug\ImageStylesCommand.
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\Command;
13 use Drupal\Core\Entity\EntityTypeManagerInterface;
14
15 /**
16  * Class StylesDebugCommand
17  *
18  * @package Drupal\Console\Command\Debug
19  */
20 class ImageStylesCommand extends Command
21 {
22     /**
23      * @var EntityTypeManagerInterface
24      */
25     protected $entityTypeManager;
26
27     /**
28      * ImageStylesCommand constructor.
29      *
30      * @param EntityTypeManagerInterface $entityTypeManager
31      */
32     public function __construct(EntityTypeManagerInterface $entityTypeManager)
33     {
34         $this->entityTypeManager = $entityTypeManager;
35         parent::__construct();
36     }
37
38     /**
39      * {@inheritdoc}
40      */
41     protected function configure()
42     {
43         $this
44             ->setName('debug:image:styles')
45             ->setDescription($this->trans('commands.debug.image.styles.description'))
46             ->setAliases(['dis']);
47     }
48
49     /**
50      * {@inheritdoc}
51      */
52     protected function execute(InputInterface $input, OutputInterface $output)
53     {
54         $imageStyle = $this->entityTypeManager->getStorage('image_style');
55
56         $this->getIo()->newLine();
57         $this->getIo()->comment(
58             $this->trans('commands.debug.image.styles.messages.styles-list')
59         );
60
61         if ($imageStyle) {
62             $this->imageStyleList($imageStyle);
63         }
64
65         return 0;
66     }
67
68     /**
69      * @param $imageStyle
70      */
71     protected function imageStyleList($imageStyle)
72     {
73         $tableHeader = [
74           $this->trans('commands.debug.image.styles.messages.styles-name'),
75           $this->trans('commands.debug.image.styles.messages.styles-label')
76         ];
77
78         $tableRows = [];
79
80         foreach ($imageStyle->loadMultiple() as $styles) {
81             $tableRows[] = [
82               $styles->get('name'),
83               $styles->get('label')
84             ];
85         }
86
87         $this->getIo()->table(
88             $tableHeader,
89             $tableRows
90         );
91     }
92 }