-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli.php
45 lines (37 loc) · 1.67 KB
/
cli.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env php
<?php
declare(strict_types = 1);
use App\Console\ClearExpiredTokensCommand;
use App\Console\CreateClientCommand;
use App\Console\CreateUserCommand;
use App\Manager\AccessTokenManager;
use App\Manager\RefreshTokenManager;
use Doctrine\ORM\EntityManager;
use Psr\Log\LoggerInterface;
use Symfony\Component\Console\Application;
use Doctrine\Migrations\Configuration\EntityManager\ExistingEntityManager;
use Doctrine\Migrations\Configuration\Migration\PhpFile;
use Doctrine\Migrations\DependencyFactory;
use Doctrine\ORM\Tools\Console\ConsoleRunner;
use Doctrine\ORM\Tools\Console\EntityManagerProvider\SingleManagerProvider;
use Doctrine\Migrations\Tools\Console\ConsoleRunner as ConsoleRunnerMigrations;
$container = require __DIR__ . '/config/bootstrap.php';
$entityManager = $container->get(EntityManager::class);
$logger = $container->get(LoggerInterface::class);
$dependencyFactory = DependencyFactory::fromEntityManager(new PhpFile('config/migrations.php'), new ExistingEntityManager($entityManager));
$cli = new Application('OAuth 2.0 Server console commands');
// Custom commands
$cli->addCommands([
new CreateClientCommand($entityManager),
new CreateUserCommand($entityManager),
new ClearExpiredTokensCommand(
new RefreshTokenManager($logger, $entityManager),
new AccessTokenManager($logger, $entityManager)
),
]);
// ORM and dbal commands
ConsoleRunner::addCommands($cli, new SingleManagerProvider($entityManager));
// Migration commands
// https://www.doctrine-project.org/projects/doctrine-migrations/en/3.5/reference/custom-integration.html#custom-integration
ConsoleRunnerMigrations::addCommands($cli, $dependencyFactory);
$cli->run();