class RecipeInfoCommand
Shows information about a particular recipe.
@internal This API is experimental.
Hierarchy
- class \Drupal\Core\Recipe\RecipeInfoCommand extends \Symfony\Component\Console\Command\Command uses \Drupal\Core\Command\BootableCommandTrait
Expanded class hierarchy of RecipeInfoCommand
File
-
core/
lib/ Drupal/ Core/ Recipe/ RecipeInfoCommand.php, line 20
Namespace
Drupal\Core\RecipeView source
final class RecipeInfoCommand extends Command {
use BootableCommandTrait;
public function __construct($class_loader) {
parent::__construct('recipe:info');
$this->classLoader = $class_loader;
}
/**
* {@inheritdoc}
*/
protected function configure() : void {
$this->setDescription('Shows information about a recipe.')
->addArgument('path', InputArgument::REQUIRED, 'The path to the recipe\'s folder');
}
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output) : int {
$io = new SymfonyStyle($input, $output);
$recipe_path = $input->getArgument('path');
if (!is_string($recipe_path) || !is_dir($recipe_path)) {
$io->error(sprintf('The supplied path %s is not a directory', $recipe_path));
return 1;
}
$this->boot();
$recipe = Recipe::createFromDirectory($recipe_path);
$io->section('Description');
$io->text($recipe->description);
$io->section('Inputs');
$descriptions = $recipe->input
->describeAll();
if ($descriptions) {
// Passing NULL as the callable to array_map() makes it act like a Python
// zip() operation.
// @see https://docs.python.org/3.8/library/functions.html#zip
$rows = array_map(NULL, array_keys($descriptions), $descriptions);
$io->table([
'Name',
'Description',
], $rows);
}
else {
$io->writeln("This recipe does not accept any input.");
}
return 0;
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
BootableCommandTrait::$classLoader | protected | property | The class loader. |
BootableCommandTrait::boot | protected | function | Boots up a Drupal environment. |
BootableCommandTrait::getSitePath | protected | function | Gets the site path. |
RecipeInfoCommand::configure | protected | function | |
RecipeInfoCommand::execute | protected | function | |
RecipeInfoCommand::__construct | public | function |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.