Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / drush / drush / tests / resources / modules / d8 / woot / src / Generators / ExampleGenerator.php
1 <?php
2
3 namespace Drupal\woot\Generators;
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
10 class ExampleGenerator extends BaseGenerator
11 {
12     protected $name = 'woot-example';
13     protected $description = 'Generates a woot.';
14     protected $alias = 'wootex';
15     protected $templatePath = __DIR__;
16
17     // We don't actually use this service. This illustrates how to inject a dependency into a Generator.
18     protected $moduleHandler;
19
20     public function __construct($moduleHandler = null, $name = null)
21     {
22         parent::__construct($name);
23         $this->moduleHandler = $moduleHandler;
24     }
25
26     /**
27      * {@inheritdoc}
28      */
29     protected function interact(InputInterface $input, OutputInterface $output)
30     {
31         $questions = Utils::defaultQuestions();
32
33         $vars = &$this->collectVars($input, $output, $questions);
34         $vars['class'] = Utils::camelize('Example_' . $vars['machine_name'] . '_Commands');
35
36         $this->addFile()
37             ->path('src/Commands/{class}.php')
38             ->template('example-generator.twig');
39     }
40 }