Final Class Yiisoft\Yii\Cycle\Command\Schema\SchemaCommand
| Inheritance | Yiisoft\Yii\Cycle\Command\Schema\SchemaCommand » Symfony\Component\Console\Command\Command |
|---|
Public Methods
| Method | Description | Defined By |
|---|---|---|
| __construct() | Yiisoft\Yii\Cycle\Command\Schema\SchemaCommand |
Protected Methods
| Method | Description | Defined By |
|---|---|---|
| configure() | Yiisoft\Yii\Cycle\Command\Schema\SchemaCommand | |
| execute() | Yiisoft\Yii\Cycle\Command\Schema\SchemaCommand |
Method Details
| public mixed __construct ( Yiisoft\Yii\Cycle\Command\CycleDependencyProxy $promise ) | ||
| $promise | Yiisoft\Yii\Cycle\Command\CycleDependencyProxy | |
public function __construct(private readonly CycleDependencyProxy $promise)
{
parent::__construct();
}
| protected void configure ( ) |
#[\Override]
protected function configure(): void
{
$this->addArgument('role', InputArgument::OPTIONAL, 'Roles to display (separated by ",").');
}
| protected integer execute ( \Symfony\Component\Console\Input\InputInterface $input, \Symfony\Component\Console\Output\OutputInterface $output ) | ||
| $input | \Symfony\Component\Console\Input\InputInterface | |
| $output | \Symfony\Component\Console\Output\OutputInterface | |
#[\Override]
protected function execute(InputInterface $input, OutputInterface $output): int
{
/** @var string|null $roleArgument */
$roleArgument = $input->getArgument('role');
$schema = $this->promise->getSchema();
$roles = $roleArgument !== null ? explode(',', $roleArgument) : $schema->getRoles();
$schemaArray = (new SchemaToArrayConverter())->convert($schema);
$notFound = [];
$found = [];
foreach ($roles as $role) {
if (!\array_key_exists($role, $schemaArray)) {
$notFound[] = $role;
continue;
}
$found[$role] = $schemaArray[$role];
}
$renderer = new OutputSchemaRenderer(OutputSchemaRenderer::FORMAT_CONSOLE_COLOR);
$output->write($renderer->render($found));
if ($notFound !== []) {
$output->writeln(sprintf('<fg=red>Undefined roles: %s</>', implode(', ', $notFound)));
}
return self::SUCCESS;
}
Signup or Login in order to comment.