Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / chi-teck / drupal-code-generator / src / Command / Drupal_8 / Plugin / Field / Widget.php
diff --git a/vendor/chi-teck/drupal-code-generator/src/Command/Drupal_8/Plugin/Field/Widget.php b/vendor/chi-teck/drupal-code-generator/src/Command/Drupal_8/Plugin/Field/Widget.php
new file mode 100644 (file)
index 0000000..dd4f0f5
--- /dev/null
@@ -0,0 +1,38 @@
+<?php
+
+namespace DrupalCodeGenerator\Command\Drupal_8\Plugin\Field;
+
+use DrupalCodeGenerator\Command\BaseGenerator;
+use DrupalCodeGenerator\Utils;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Output\OutputInterface;
+
+/**
+ * Implements d8:plugin:field:widget command.
+ */
+class Widget extends BaseGenerator {
+
+  protected $name = 'd8:plugin:field:widget';
+  protected $description = 'Generates field widget plugin';
+  protected $alias = 'field-widget';
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function interact(InputInterface $input, OutputInterface $output) {
+    $questions = Utils::defaultPluginQuestions();
+
+    $vars = &$this->collectVars($input, $output, $questions);
+    $vars['class'] = Utils::camelize($vars['plugin_label'] . 'Widget');
+
+    $this->addFile()
+      ->path('src/Plugin/Field/FieldWidget/{class}.php')
+      ->template('d8/plugin/field/widget.twig');
+
+    $this->addFile()
+      ->path('config/schema/{machine_name}.schema.yml')
+      ->template('d8/plugin/field/widget-schema.twig')
+      ->action('append');
+  }
+
+}