|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace DrupalCodeGenerator\Commands\Drupal_8\Plugin; |
| 4 | + |
| 5 | +use Symfony\Component\Console\Input\InputInterface; |
| 6 | +use Symfony\Component\Console\Output\OutputInterface; |
| 7 | +use DrupalCodeGenerator\Commands\BaseGenerator; |
| 8 | + |
| 9 | +/** |
| 10 | + * Implements d8:plugin:action command. |
| 11 | + */ |
| 12 | +class Action extends BaseGenerator { |
| 13 | + |
| 14 | + protected $name = 'd8:plugin:action'; |
| 15 | + protected $description = 'Generates action plugin'; |
| 16 | + protected $alias = 'action'; |
| 17 | + |
| 18 | + /** |
| 19 | + * {@inheritdoc} |
| 20 | + */ |
| 21 | + protected function interact(InputInterface $input, OutputInterface $output) { |
| 22 | + |
| 23 | + $questions = [ |
| 24 | + 'name' => ['Module name'], |
| 25 | + 'machine_name' => ['Module machine name'], |
| 26 | + 'plugin_label' => ['Plugin label', 'Example'], |
| 27 | + 'plugin_id' => ['Plugin ID'], |
| 28 | + 'category' => ['Action category', 'Custom'], |
| 29 | + 'configurable' => ['Make the action configurable', 'no'] |
| 30 | + ]; |
| 31 | + |
| 32 | + $vars = $this->collectVars($input, $output, $questions); |
| 33 | + $vars['class'] = $this->human2class($vars['plugin_label']); |
| 34 | + |
| 35 | + $path = $this->createPath('src/Plugin/Action/', $vars['class'] . '.php', $vars['machine_name']); |
| 36 | + $this->files[$path] = $this->render('d8/plugin/action.twig', $vars); |
| 37 | + } |
| 38 | + |
| 39 | +} |
0 commit comments