924604125fa8e8c8c4a6da192700e3bd3d0fe812
[yaffs-website] / vendor / chi-teck / drupal-code-generator / src / Command / Drupal_8 / Plugin / Field / Formatter.php
1 <?php
2
3 namespace DrupalCodeGenerator\Command\Drupal_8\Plugin\Field;
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\ConfirmationQuestion;
10
11 /**
12  * Implements d8:plugin:field:formatter command.
13  */
14 class Formatter extends BaseGenerator {
15
16   protected $name = 'd8:plugin:field:formatter';
17   protected $description = 'Generates field formatter plugin';
18   protected $alias = 'field-formatter';
19
20   /**
21    * {@inheritdoc}
22    */
23   protected function interact(InputInterface $input, OutputInterface $output) {
24     $questions = Utils::defaultPluginQuestions();
25     $questions['configurable'] = new ConfirmationQuestion('Make the formatter configurable?', FALSE);
26
27     $vars = &$this->collectVars($input, $output, $questions);
28     $vars['class'] = Utils::camelize($vars['plugin_label']) . 'Formatter';
29
30     $this->addFile()
31       ->path('src/Plugin/Field/FieldFormatter/{class}.php')
32       ->template('d8/plugin/field/formatter.twig');
33
34     if ($vars['configurable']) {
35       $this->addFile()
36         ->path('config/schema/{machine_name}.schema.yml')
37         ->template('d8/plugin/field/formatter-schema.twig')
38         ->action('append');
39     }
40
41   }
42
43 }