function GenerateCommandTrait::generate
Generates with the given plugin, from the command's arguments and options.
Parameters
string $plugin_id: The DevelGenerate plugin ID.
\Symfony\Component\Console\Input\InputInterface $input: The input.
\Symfony\Component\Console\Output\OutputInterface $output: The output.
string[] $modules: The modules that must be installed.
7 calls to GenerateCommandTrait::generate()
- GenerateBlockCommand::__invoke in devel_generate/
src/ Command/ GenerateBlockCommand.php - Create Block content blocks.
- GenerateContentCommand::__invoke in devel_generate/
src/ Command/ GenerateContentCommand.php - Create content.
- GenerateMediaCommand::__invoke in devel_generate/
src/ Command/ GenerateMediaCommand.php - Create media items.
- GenerateMenusCommand::__invoke in devel_generate/
src/ Command/ GenerateMenusCommand.php - Create menus.
- GenerateTermsCommand::__invoke in devel_generate/
src/ Command/ GenerateTermsCommand.php - Create terms in specified vocabulary.
File
-
devel_generate/
src/ Command/ GenerateCommandTrait.php, line 42
Class
- GenerateCommandTrait
- Runs a DevelGenerate plugin from a console command.
Namespace
Drupal\devel_generate\CommandCode
protected function generate(string $plugin_id, InputInterface $input, OutputInterface $output, array $modules = []) : int {
$missing = array_filter($modules, fn(string $module): bool => !$this->moduleHandler
->moduleExists($module));
if ($missing !== []) {
throw new \RuntimeException(sprintf('Install these modules first: %s', implode(', ', $missing)));
}
/** @var \Drupal\devel_generate\DevelGenerateBaseInterface $instance */
$instance = $this->manager
->createInstance($plugin_id, []);
try {
$parameters = $instance->validateDrushParams($input->getArguments(), $input->getOptions());
$instance->generate($parameters);
$this->processBatch();
} finally {
$this->writeMessages($input, $output);
}
return Command::SUCCESS;
}