Final Class Yiisoft\Yii\Cycle\Command\Schema\SchemaPhpCommand
| 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 ( \ | ||
| $aliases | \ |
|
| $promise | Yiisoft\ |
|
public function __construct(
private readonly Aliases $aliases,
private readonly CycleDependencyProxy $promise,
) {
parent::__construct();
}
| protected void configure ( ) |
protected function configure(): void
{
$this->addArgument('file', InputArgument::OPTIONAL, 'file');
}
| protected integer execute ( \ | ||
| $input | \ |
|
| $output | \ |
|
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;
}
User Contributed Notes
Leave a comment
Join the conversation to share a note.