Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / vendor / chi-teck / drupal-code-generator / src / Command / Drupal_8 / Plugin / Field / Widget.php
index dd4f0f577d8b0f113b78952ab1704ce6c7b7a3bc..e7d13c084b993626bf4e5dc7b40f11a887bb5247 100644 (file)
@@ -6,6 +6,7 @@ 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;
 
 /**
  * Implements d8:plugin:field:widget command.
@@ -21,18 +22,21 @@ class Widget extends BaseGenerator {
    */
   protected function interact(InputInterface $input, OutputInterface $output) {
     $questions = Utils::defaultPluginQuestions();
+    $questions['configurable'] = new ConfirmationQuestion('Make the widget configurable?', FALSE);
 
     $vars = &$this->collectVars($input, $output, $questions);
-    $vars['class'] = Utils::camelize($vars['plugin_label'] . 'Widget');
+    $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');
+    if ($vars['configurable']) {
+      $this->addFile()
+        ->path('config/schema/{machine_name}.schema.yml')
+        ->template('d8/plugin/field/widget-schema.twig')
+        ->action('append');
+    }
   }
 
 }