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 / Formatter.php
index bea87b7231f4f4bf6bb1b4f27cbc08a878d06d67..924604125fa8e8c8c4a6da192700e3bd3d0fe812 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:formatter command.
@@ -21,18 +22,22 @@ class Formatter extends BaseGenerator {
    */
   protected function interact(InputInterface $input, OutputInterface $output) {
     $questions = Utils::defaultPluginQuestions();
+    $questions['configurable'] = new ConfirmationQuestion('Make the formatter configurable?', FALSE);
 
     $vars = &$this->collectVars($input, $output, $questions);
-    $vars['class'] = Utils::camelize($vars['plugin_label'] . 'Formatter');
+    $vars['class'] = Utils::camelize($vars['plugin_label']) . 'Formatter';
 
     $this->addFile()
       ->path('src/Plugin/Field/FieldFormatter/{class}.php')
       ->template('d8/plugin/field/formatter.twig');
 
-    $this->addFile()
-      ->path('config/schema/{machine_name}.schema.yml')
-      ->template('d8/plugin/field/formatter-schema.twig')
-      ->action('append');
+    if ($vars['configurable']) {
+      $this->addFile()
+        ->path('config/schema/{machine_name}.schema.yml')
+        ->template('d8/plugin/field/formatter-schema.twig')
+        ->action('append');
+    }
+
   }
 
 }