3 namespace DrupalCodeGenerator\Command\Drupal_8\Plugin\Field;
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;
12 * Implements d8:plugin:field:formatter command.
14 class Formatter extends BaseGenerator {
16 protected $name = 'd8:plugin:field:formatter';
17 protected $description = 'Generates field formatter plugin';
18 protected $alias = 'field-formatter';
23 protected function interact(InputInterface $input, OutputInterface $output) {
24 $questions = Utils::defaultPluginQuestions();
25 $questions['configurable'] = new ConfirmationQuestion('Make the formatter configurable?', FALSE);
27 $vars = &$this->collectVars($input, $output, $questions);
28 $vars['class'] = Utils::camelize($vars['plugin_label']) . 'Formatter';
31 ->path('src/Plugin/Field/FieldFormatter/{class}.php')
32 ->template('d8/plugin/field/formatter.twig');
34 if ($vars['configurable']) {
36 ->path('config/schema/{machine_name}.schema.yml')
37 ->template('d8/plugin/field/formatter-schema.twig')