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
diff --git a/vendor/drush/drush/tests/resources/modules/d8/woot/src/Generators/ExampleGenerator.php b/vendor/drush/drush/tests/resources/modules/d8/woot/src/Generators/ExampleGenerator.php
new file mode 100644 (file)
index 0000000..17a6473
--- /dev/null
@@ -0,0 +1,40 @@
+<?php
+
+namespace Drupal\woot\Generators;
+
+use DrupalCodeGenerator\Command\BaseGenerator;
+use DrupalCodeGenerator\Utils;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Output\OutputInterface;
+
+class ExampleGenerator extends BaseGenerator
+{
+    protected $name = 'woot-example';
+    protected $description = 'Generates a woot.';
+    protected $alias = 'wootex';
+    protected $templatePath = __DIR__;
+
+    // We don't actually use this service. This illustrates how to inject a dependency into a Generator.
+    protected $moduleHandler;
+
+    public function __construct($moduleHandler = null, $name = null)
+    {
+        parent::__construct($name);
+        $this->moduleHandler = $moduleHandler;
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    protected function interact(InputInterface $input, OutputInterface $output)
+    {
+        $questions = Utils::defaultQuestions();
+
+        $vars = &$this->collectVars($input, $output, $questions);
+        $vars['class'] = Utils::camelize('Example_' . $vars['machine_name'] . '_Commands');
+
+        $this->addFile()
+            ->path('src/Commands/{class}.php')
+            ->template('example-generator.twig');
+    }
+}