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;
/**
$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');
+ }
}
}