Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / chi-teck / drupal-code-generator / src / Command / Drupal_8 / Plugin / Action.php
diff --git a/vendor/chi-teck/drupal-code-generator/src/Command/Drupal_8/Plugin/Action.php b/vendor/chi-teck/drupal-code-generator/src/Command/Drupal_8/Plugin/Action.php
new file mode 100644 (file)
index 0000000..63b4833
--- /dev/null
@@ -0,0 +1,48 @@
+<?php
+
+namespace DrupalCodeGenerator\Command\Drupal_8\Plugin;
+
+use DrupalCodeGenerator\Command\BaseGenerator;
+use DrupalCodeGenerator\Utils;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Output\OutputInterface;
+use Symfony\Component\Console\Question\ConfirmationQuestion;
+use Symfony\Component\Console\Question\Question;
+
+/**
+ * Implements d8:plugin:action command.
+ */
+class Action extends BaseGenerator {
+
+  protected $name = 'd8:plugin:action';
+  protected $description = 'Generates action plugin';
+  protected $alias = 'action';
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function interact(InputInterface $input, OutputInterface $output) {
+    $questions = Utils::defaultPluginQuestions() + [
+      'category' => new Question('Action category', 'Custom'),
+      'configurable' => new ConfirmationQuestion('Make the action configurable?', FALSE),
+    ];
+    // Plugin label should declare an action.
+    $questions['plugin_label'] = new Question('Action label', 'Update node title');
+
+    $vars = &$this->collectVars($input, $output, $questions);
+    $vars['class'] = Utils::camelize($vars['plugin_label']);
+
+    $this->addFile()
+      ->path('src/Plugin/Action/{class}.php')
+      ->template('d8/plugin/action.twig');
+
+    if ($vars['configurable']) {
+      $this->addFile()
+        ->path('config/schema/{machine_name}.schema.yml')
+        ->template('d8/plugin/action-schema.twig')
+        ->action('append');
+    }
+
+  }
+
+}