-
-
Notifications
You must be signed in to change notification settings - Fork 391
/
Copy pathConsoleRunner.php
70 lines (61 loc) · 2.24 KB
/
ConsoleRunner.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
declare(strict_types=1);
namespace Doctrine\Migrations\Tools\Console;
use Doctrine\Migrations\Tools\Console\Command\AbstractCommand;
use Doctrine\Migrations\Tools\Console\Command\DiffCommand;
use Doctrine\Migrations\Tools\Console\Command\DumpSchemaCommand;
use Doctrine\Migrations\Tools\Console\Command\ExecuteCommand;
use Doctrine\Migrations\Tools\Console\Command\GenerateCommand;
use Doctrine\Migrations\Tools\Console\Command\LatestCommand;
use Doctrine\Migrations\Tools\Console\Command\MigrateCommand;
use Doctrine\Migrations\Tools\Console\Command\RollupCommand;
use Doctrine\Migrations\Tools\Console\Command\StatusCommand;
use Doctrine\Migrations\Tools\Console\Command\UpToDateCommand;
use Doctrine\Migrations\Tools\Console\Command\VersionCommand;
use PackageVersions\Versions;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Helper\HelperSet;
/**
* The ConsoleRunner class is used to create the Symfony Console application for the Doctrine Migrations console.
*
* @see bin/doctrine-migrations.php
*
* @internal
*/
class ConsoleRunner
{
/** @param AbstractCommand[] $commands */
public static function run(HelperSet $helperSet, array $commands = []) : void
{
$cli = static::createApplication($helperSet, $commands);
$cli->run();
}
/** @param AbstractCommand[] $commands */
public static function createApplication(HelperSet $helperSet, array $commands = []) : Application
{
$cli = new Application('Doctrine Migrations', Versions::getVersion('doctrine/migrations'));
$cli->setCatchExceptions(true);
$cli->setHelperSet($helperSet);
self::addCommands($cli);
$cli->addCommands($commands);
return $cli;
}
public static function addCommands(Application $cli) : void
{
$cli->addCommands([
new DumpSchemaCommand(),
new ExecuteCommand(),
new GenerateCommand(),
new LatestCommand(),
new MigrateCommand(),
new RollupCommand(),
new StatusCommand(),
new VersionCommand(),
new UpToDateCommand(),
]);
if (! $cli->getHelperSet()->has('em')) {
return;
}
$cli->add(new DiffCommand());
}
}