diff options
author | polo <ordipolo@gmx.fr> | 2024-08-13 23:45:21 +0200 |
---|---|---|
committer | polo <ordipolo@gmx.fr> | 2024-08-13 23:45:21 +0200 |
commit | bf6655a534a6775d30cafa67bd801276bda1d98d (patch) | |
tree | c6381e3f6c81c33eab72508f410b165ba05f7e9c /vendor/doctrine/orm/src/Tools/Console/ConsoleRunner.php | |
parent | 94d67a4b51f8e62e7d518cce26a526ae1ec48278 (diff) | |
download | AppliGestionPHP-bf6655a534a6775d30cafa67bd801276bda1d98d.zip |
VERSION 0.2 doctrine ORM et entités
Diffstat (limited to 'vendor/doctrine/orm/src/Tools/Console/ConsoleRunner.php')
-rw-r--r-- | vendor/doctrine/orm/src/Tools/Console/ConsoleRunner.php | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/vendor/doctrine/orm/src/Tools/Console/ConsoleRunner.php b/vendor/doctrine/orm/src/Tools/Console/ConsoleRunner.php new file mode 100644 index 0000000..0a00483 --- /dev/null +++ b/vendor/doctrine/orm/src/Tools/Console/ConsoleRunner.php | |||
@@ -0,0 +1,88 @@ | |||
1 | <?php | ||
2 | |||
3 | declare(strict_types=1); | ||
4 | |||
5 | namespace Doctrine\ORM\Tools\Console; | ||
6 | |||
7 | use Composer\InstalledVersions; | ||
8 | use Doctrine\DBAL\Tools\Console as DBALConsole; | ||
9 | use Doctrine\ORM\Tools\Console\EntityManagerProvider\ConnectionFromManagerProvider; | ||
10 | use OutOfBoundsException; | ||
11 | use Symfony\Component\Console\Application; | ||
12 | use Symfony\Component\Console\Command\Command as SymfonyCommand; | ||
13 | |||
14 | use function assert; | ||
15 | use function class_exists; | ||
16 | |||
17 | /** | ||
18 | * Handles running the Console Tools inside Symfony Console context. | ||
19 | */ | ||
20 | final class ConsoleRunner | ||
21 | { | ||
22 | /** | ||
23 | * Runs console with the given helper set. | ||
24 | * | ||
25 | * @param SymfonyCommand[] $commands | ||
26 | */ | ||
27 | public static function run(EntityManagerProvider $entityManagerProvider, array $commands = []): void | ||
28 | { | ||
29 | $cli = self::createApplication($entityManagerProvider, $commands); | ||
30 | $cli->run(); | ||
31 | } | ||
32 | |||
33 | /** | ||
34 | * Creates a console application with the given helperset and | ||
35 | * optional commands. | ||
36 | * | ||
37 | * @param SymfonyCommand[] $commands | ||
38 | * | ||
39 | * @throws OutOfBoundsException | ||
40 | */ | ||
41 | public static function createApplication( | ||
42 | EntityManagerProvider $entityManagerProvider, | ||
43 | array $commands = [], | ||
44 | ): Application { | ||
45 | $version = InstalledVersions::getVersion('doctrine/orm'); | ||
46 | assert($version !== null); | ||
47 | |||
48 | $cli = new Application('Doctrine Command Line Interface', $version); | ||
49 | $cli->setCatchExceptions(true); | ||
50 | |||
51 | self::addCommands($cli, $entityManagerProvider); | ||
52 | $cli->addCommands($commands); | ||
53 | |||
54 | return $cli; | ||
55 | } | ||
56 | |||
57 | public static function addCommands(Application $cli, EntityManagerProvider $entityManagerProvider): void | ||
58 | { | ||
59 | $connectionProvider = new ConnectionFromManagerProvider($entityManagerProvider); | ||
60 | |||
61 | if (class_exists(DBALConsole\Command\ReservedWordsCommand::class)) { | ||
62 | $cli->add(new DBALConsole\Command\ReservedWordsCommand($connectionProvider)); | ||
63 | } | ||
64 | |||
65 | $cli->addCommands( | ||
66 | [ | ||
67 | // DBAL Commands | ||
68 | new DBALConsole\Command\RunSqlCommand($connectionProvider), | ||
69 | |||
70 | // ORM Commands | ||
71 | new Command\ClearCache\CollectionRegionCommand($entityManagerProvider), | ||
72 | new Command\ClearCache\EntityRegionCommand($entityManagerProvider), | ||
73 | new Command\ClearCache\MetadataCommand($entityManagerProvider), | ||
74 | new Command\ClearCache\QueryCommand($entityManagerProvider), | ||
75 | new Command\ClearCache\QueryRegionCommand($entityManagerProvider), | ||
76 | new Command\ClearCache\ResultCommand($entityManagerProvider), | ||
77 | new Command\SchemaTool\CreateCommand($entityManagerProvider), | ||
78 | new Command\SchemaTool\UpdateCommand($entityManagerProvider), | ||
79 | new Command\SchemaTool\DropCommand($entityManagerProvider), | ||
80 | new Command\GenerateProxiesCommand($entityManagerProvider), | ||
81 | new Command\RunDqlCommand($entityManagerProvider), | ||
82 | new Command\ValidateSchemaCommand($entityManagerProvider), | ||
83 | new Command\InfoCommand($entityManagerProvider), | ||
84 | new Command\MappingDescribeCommand($entityManagerProvider), | ||
85 | ], | ||
86 | ); | ||
87 | } | ||
88 | } | ||