c285f62004fe2da7fb47ce40f5ba3385a5b3528f
[yaffs-website] / vendor / chi-teck / drupal-code-generator / src / Command / Drupal_8 / Plugin / Block.php
1 <?php
2
3 namespace DrupalCodeGenerator\Command\Drupal_8\Plugin;
4
5 use DrupalCodeGenerator\Command\BaseGenerator;
6 use DrupalCodeGenerator\Utils;
7 use Symfony\Component\Console\Input\InputInterface;
8 use Symfony\Component\Console\Output\OutputInterface;
9 use Symfony\Component\Console\Question\Question;
10
11 /**
12  * Implements d8:plugin:block command.
13  */
14 class Block extends BaseGenerator {
15
16   protected $name = 'd8:plugin:block';
17   protected $description = 'Generates block plugin';
18   protected $alias = 'block';
19
20   /**
21    * {@inheritdoc}
22    */
23   protected function interact(InputInterface $input, OutputInterface $output) {
24     $questions = Utils::defaultPluginQuestions();
25     $questions['plugin_label'] = new Question('Block admin label', 'Example');
26     $questions['plugin_label']->setValidator([Utils::class, 'validateRequired']);
27     $questions['category'] = new Question('Block category', 'Custom');
28
29     $vars = &$this->collectVars($input, $output, $questions);
30     $vars['class'] = Utils::camelize($vars['plugin_label'] . 'Block');
31
32     $this->addFile()
33       ->path('src/Plugin/Block/{class}.php')
34       ->template('d8/plugin/block.twig');
35
36     $this->addFile()
37       ->path('config/schema/{machine_name}.schema.yml')
38       ->template('d8/plugin/block-schema.twig')
39       ->action('append');
40   }
41
42 }