Final Class Yiisoft\Yii\Cycle\Command\Schema\SchemaCommand
| Inheritance | Yiisoft\ |
|---|
Public Methods
| Method | Description | Defined By |
|---|---|---|
| __construct() | Yiisoft\ |
Protected Methods
| Method | Description | Defined By |
|---|---|---|
| configure() | Yiisoft\ |
|
| execute() | Yiisoft\ |
Method Details
| public mixed __construct ( Yiisoft\ | ||
| $promise | Yiisoft\ |
|
public function __construct(private readonly CycleDependencyProxy $promise)
{
parent::__construct();
}
| protected void configure ( ) |
protected function configure(): void
{
$this->addArgument('role', InputArgument::OPTIONAL, 'Roles to display (separated by ",").');
}
| protected integer execute ( \ | ||
| $input | \ |
|
| $output | \ |
|
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;
}
User Contributed Notes
Leave a comment
Join the conversation to share a note.