Yaffs site version 1.1
[yaffs-website] / vendor / drupal / console / src / Command / Generate / EntityConfigCommand.php
1 <?php
2
3 /**
4  * @file
5  * Contains \Drupal\Console\Command\Generate\EntityConfigCommand.
6  */
7
8 namespace Drupal\Console\Command\Generate;
9
10 use Symfony\Component\Console\Input\InputInterface;
11 use Symfony\Component\Console\Input\InputOption;
12 use Symfony\Component\Console\Output\OutputInterface;
13 use Drupal\Console\Generator\EntityConfigGenerator;
14 use Drupal\Console\Extension\Manager;
15 use Drupal\Console\Utils\Validator;
16 use Drupal\Console\Core\Utils\StringConverter;
17
18 class EntityConfigCommand extends EntityCommand
19 {
20     /**
21  * @var Manager
22 */
23     protected $extensionManager;
24
25     /**
26  * @var EntityConfigGenerator
27 */
28     protected $generator;
29
30     /**
31      * @var Validator
32      */
33     protected $validator;
34
35     /**
36      * @var StringConverter
37      */
38     protected $stringConverter;
39
40     /**
41      * EntityConfigCommand constructor.
42      *
43      * @param Manager               $extensionManager
44      * @param EntityConfigGenerator $generator
45      * @param Validator             $validator
46      * @param StringConverter       $stringConverter
47      */
48     public function __construct(
49         Manager $extensionManager,
50         EntityConfigGenerator $generator,
51         Validator $validator,
52         StringConverter $stringConverter
53     ) {
54         $this->extensionManager = $extensionManager;
55         $this->generator = $generator;
56         $this->validator = $validator;
57         $this->stringConverter = $stringConverter;
58         parent::__construct();
59     }
60
61
62     protected function configure()
63     {
64         $this->setEntityType('EntityConfig');
65         $this->setCommandName('generate:entity:config');
66         parent::configure();
67
68         $this->addOption(
69             'bundle-of',
70             null,
71             InputOption::VALUE_NONE,
72             $this->trans('commands.generate.entity.config.options.bundle-of')
73         );
74     }
75
76     /**
77      * {@inheritdoc}
78      */
79     protected function interact(InputInterface $input, OutputInterface $output)
80     {
81         parent::interact($input, $output);
82     }
83
84     /**
85      * {@inheritdoc}
86      */
87     protected function execute(InputInterface $input, OutputInterface $output)
88     {
89         $module = $input->getOption('module');
90         $entity_class = $input->getOption('entity-class');
91         $entity_name = $input->getOption('entity-name');
92         $label = $input->getOption('label');
93         $bundle_of = $input->getOption('bundle-of');
94         $base_path = $input->getOption('base-path');
95
96         $this
97             ->generator
98             ->generate($module, $entity_name, $entity_class, $label, $base_path, $bundle_of);
99     }
100 }