Final Class Yiisoft\Yii\Cycle\Command\Schema\SchemaPhpCommand
| Inheritance | Yiisoft\Yii\Cycle\Command\Schema\SchemaPhpCommand » Symfony\Component\Console\Command\Command |
|---|
Public Methods
| Method | Description | Defined By |
|---|---|---|
| __construct() | Yiisoft\Yii\Cycle\Command\Schema\SchemaPhpCommand |
Protected Methods
| Method | Description | Defined By |
|---|---|---|
| configure() | Yiisoft\Yii\Cycle\Command\Schema\SchemaPhpCommand | |
| execute() | Yiisoft\Yii\Cycle\Command\Schema\SchemaPhpCommand |
Method Details
| public mixed __construct ( \Yiisoft\Aliases\Aliases $aliases, Yiisoft\Yii\Cycle\Command\CycleDependencyProxy $promise ) | ||
| $aliases | \Yiisoft\Aliases\Aliases | |
| $promise | Yiisoft\Yii\Cycle\Command\CycleDependencyProxy | |
public function __construct(
private readonly Aliases $aliases,
private readonly CycleDependencyProxy $promise,
) {
parent::__construct();
}
| protected void configure ( ) |
#[\Override]
protected function configure(): void
{
$this->addArgument('file', InputArgument::OPTIONAL, 'file');
}
| 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 $file */
$file = $input->getArgument('file');
$converter = new SchemaToArrayConverter();
$schemaArray = $converter->convert($this->promise->getSchema());
$content = (new PhpSchemaRenderer())->render($schemaArray);
if ($file === null) {
$output->write($content);
return self::SUCCESS;
}
$file = $this->aliases->get($file);
$output->writeln("Destination: <fg=cyan>$file</>");
$dir = dirname($file);
if (!is_dir($dir)) {
$output->writeln('Destination directory not found.');
return self::FAILURE;
}
if (file_put_contents($file, $content) === false) {
$output->writeln('<fg=red>Failed to write content to file.</>');
return self::FAILURE;
}
return self::SUCCESS;
}
Signup or Login in order to comment.