UnderCurrent/app/Console/OrmCommand.php

33 lines
916 B
PHP

<?php
namespace App\Console;
use Ardent\Undercurrent\Attribute\Command;
use Ardent\Undercurrent\Console\BaseCommand;
use Ardent\Undercurrent\Console\Output;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Tools\Console\ConsoleRunner;
use Doctrine\ORM\Tools\Console\EntityManagerProvider\SingleManagerProvider;
use Symfony\Component\Console\Input\ArgvInput;
#[Command('orm')]
class OrmCommand extends BaseCommand
{
public function __construct(
private readonly EntityManager $entityManager,
)
{
}
protected function run(Output $output): void
{
// strip out the 'orm' part to pass it on naturally
$argv = $_SERVER['argv'];
unset($argv[1]);
$argv = array_values($argv);
$cli = ConsoleRunner::createApplication(new SingleManagerProvider($this->entityManager));
$cli->run(new ArgvInput($argv));
}
}