3 namespace DrupalCodeGenerator\Command\Drupal_8\Plugin;
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\ChoiceQuestion;
12 * Implements d8:plugin:filter command.
14 class Filter extends BaseGenerator {
16 protected $name = 'd8:plugin:filter';
17 protected $description = 'Generates filter plugin';
18 protected $alias = 'filter';
23 protected function interact(InputInterface $input, OutputInterface $output) {
24 $questions = Utils::defaultPluginQuestions();
27 'TYPE_HTML_RESTRICTOR' => 'HTML restrictor',
28 'TYPE_MARKUP_LANGUAGE' => 'Markup language',
29 'TYPE_TRANSFORM_IRREVERSIBLE' => 'Irreversible transformation',
30 'TYPE_TRANSFORM_REVERSIBLE' => 'Reversible transformation',
32 $choices = array_values($filter_types);
33 // Start choices list form '1'.
34 array_unshift($choices, NULL);
36 $questions['filter_type'] = new ChoiceQuestion('Filter type', $choices);
38 $vars = &$this->collectVars($input, $output, $questions);
39 $vars['class'] = Utils::camelize($vars['plugin_label']);
40 $vars['filter_type'] = array_search($vars['filter_type'], $filter_types);
43 ->path('src/Plugin/Filter/{class}.php')
44 ->template('d8/plugin/filter.twig');
47 ->path('config/schema/{machine_name}.schema.yml')
48 ->template('d8/plugin/filter-schema.twig')