0 follower

Final Class Yiisoft\Yii\Cycle\Command\Schema\SchemaCommand

InheritanceYiisoft\Yii\Cycle\Command\Schema\SchemaCommand » Symfony\Component\Console\Command\Command

Method Details

Hide inherited methods

__construct() public method

public mixed __construct ( Yiisoft\Yii\Cycle\Command\CycleDependencyProxy $promise )
$promise Yiisoft\Yii\Cycle\Command\CycleDependencyProxy

                public function __construct(private readonly CycleDependencyProxy $promise)
{
    parent::__construct();
}

            
configure() protected method

protected void configure ( )

                #[\Override]
protected function configure(): void
{
    $this->addArgument('role', InputArgument::OPTIONAL, 'Roles to display (separated by ",").');
}

            
execute() protected method

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;
}