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 / Block.php
index c285f62004fe2da7fb47ce40f5ba3385a5b3528f..a3b6419a8da8d7cb5bafdfa6f9a6c90e4e333093 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;
 use Symfony\Component\Console\Question\Question;
 
 /**
@@ -25,18 +26,30 @@ class Block extends BaseGenerator {
     $questions['plugin_label'] = new Question('Block admin label', 'Example');
     $questions['plugin_label']->setValidator([Utils::class, 'validateRequired']);
     $questions['category'] = new Question('Block category', 'Custom');
+    $questions['configurable'] = new ConfirmationQuestion('Make the block configurable?', FALSE);
 
-    $vars = &$this->collectVars($input, $output, $questions);
-    $vars['class'] = Utils::camelize($vars['plugin_label'] . 'Block');
+    $this->collectVars($input, $output, $questions);
+
+    $di_question = new ConfirmationQuestion('Would you like to inject dependencies?', FALSE);
+    if ($this->ask($input, $output, $di_question)) {
+      $this->collectServices($input, $output);
+    }
+
+    $access_question = new ConfirmationQuestion('Create access callback?', FALSE);
+    $vars = &$this->collectVars($input, $output, ['access' => $access_question]);
+
+    $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');
+    if ($vars['configurable']) {
+      $this->addFile()
+        ->path('config/schema/{machine_name}.schema.yml')
+        ->template('d8/plugin/block-schema.twig')
+        ->action('append');
+    }
   }
 
 }