-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcli-config.php
64 lines (50 loc) · 2.3 KB
/
cli-config.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
<?php
/** vendor/bin/doctrine looks for a config/cli-config.php file in the project - so that's why this is here **/
/** If the bootstrap (Aurex.php) sees this variable, don't 'run' the HTTP front-controller **/
$cli = true;
require_once __DIR__ . '/vendor/autoload.php';
require_once __DIR__ . '/web/index.php';
use Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain,
Symfony\Component\Console\Application as CliApplication,
Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper,
Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper,
UseAllFive\Command\LoadDataFixturesDoctrineCommand,
Doctrine\Common\Annotations\AnnotationRegistry,
Doctrine\ORM\Mapping\Driver\AnnotationDriver,
Doctrine\Common\Annotations\AnnotationReader,
Symfony\Component\Console\Helper\HelperSet,
Doctrine\ORM\Mapping\Driver\DatabaseDriver,
Doctrine\ORM\Tools\Console\Command,
Doctrine\DBAL\Connection,
Doctrine\DBAL\Version;
/** @var Connection $db The above bootstrap creates the app object for us */
$db = $aurex['db'];
/** @var Doctrine\ORM\EntityManager $em The entity manager */
$em = $aurex['orm.em'];
$driver = new DatabaseDriver($db->getSchemaManager());
$driver->setNamespace('Aurex\Application\Entity\\');
$annotationsFile = __DIR__ . '/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php';
AnnotationRegistry::registerFile($annotationsFile);
$driverChain = new MappingDriverChain();
$driverChain->addDriver(
new AnnotationDriver(new AnnotationReader(), [__DIR__ . '/lib/Application/Model/Entity']), 'Aurex\Application\\Model\Entity\\'
);
$em->getConfiguration()->setMetadataDriverImpl($driverChain);
/** @var Symfony\Component\Console\Application $cli */
$cli = new CliApplication('Doctrine Command Line Interface', Version::VERSION);
$cli->setCatchExceptions(true);
$cli->setHelperSet(new HelperSet([
'db' => new ConnectionHelper($em->getConnection()),
'em' => new EntityManagerHelper($em)
]));
$cli->addCommands([
new Command\GenerateRepositoriesCommand,
new Command\GenerateEntitiesCommand,
new Command\ConvertMappingCommand,
new Command\ValidateSchemaCommand,
new Command\SchemaTool\CreateCommand,
new Command\SchemaTool\UpdateCommand,
new Command\GenerateProxiesCommand,
new LoadDataFixturesDoctrineCommand
]);
$cli->run();