Implement doctrine orm as command
This commit is contained in:
parent
f8d1c66934
commit
7a4a9257c3
33
app/Console/OrmCommand.php
Normal file
33
app/Console/OrmCommand.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?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));
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace App;
|
||||
|
||||
use App\Console\OrmCommand;
|
||||
use App\Console\TestCommand;
|
||||
use App\Controller\HelloWorldController;
|
||||
use Ardent\Undercurrent\Console\CommandsConfig;
|
||||
@ -19,6 +20,7 @@ class Kernel extends BaseKernel
|
||||
|
||||
$commands = new CommandsConfig();
|
||||
$commands->add(TestCommand::class);
|
||||
$commands->add(OrmCommand::class);
|
||||
$this->addCommands($container, $commands);
|
||||
}
|
||||
}
|
@ -11,4 +11,4 @@ $kernel = new Kernel(new AppConfig(__DIR__ . '/../app'));
|
||||
$container = $kernel->setup();
|
||||
|
||||
$console = new Console($container);
|
||||
$console->run();
|
||||
$console->run();
|
||||
|
Loading…
Reference in New Issue
Block a user