Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / chi-teck / drupal-code-generator / src / Command / Drupal_8 / Plugin / Block.php
diff --git a/vendor/chi-teck/drupal-code-generator/src/Command/Drupal_8/Plugin/Block.php b/vendor/chi-teck/drupal-code-generator/src/Command/Drupal_8/Plugin/Block.php
new file mode 100644 (file)
index 0000000..c285f62
--- /dev/null
@@ -0,0 +1,42 @@
+<?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\Question;
+
+/**
+ * Implements d8:plugin:block command.
+ */
+class Block extends BaseGenerator {
+
+  protected $name = 'd8:plugin:block';
+  protected $description = 'Generates block plugin';
+  protected $alias = 'block';
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function interact(InputInterface $input, OutputInterface $output) {
+    $questions = Utils::defaultPluginQuestions();
+    $questions['plugin_label'] = new Question('Block admin label', 'Example');
+    $questions['plugin_label']->setValidator([Utils::class, 'validateRequired']);
+    $questions['category'] = new Question('Block category', 'Custom');
+
+    $vars = &$this->collectVars($input, $output, $questions);
+    $vars['class'] = Utils::camelize($vars['plugin_label'] . 'Block');
+
+    $this->addFile()
+      ->path('src/Plugin/Block/{class}.php')
+      ->template('d8/plugin/block.twig');
+
+    $this->addFile()
+      ->path('config/schema/{machine_name}.schema.yml')
+      ->template('d8/plugin/block-schema.twig')
+      ->action('append');
+  }
+
+}