-
Notifications
You must be signed in to change notification settings - Fork 8
/
cli-config.php
54 lines (45 loc) · 2.21 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
<?php
use Doctrine\ORM\Tools\Setup;
use Doctrine\ORM\EntityManager;
use Doctrine\Common\Annotations\AnnotationRegistry;
$apiClassLoader = new \Doctrine\Common\ClassLoader('Application', __DIR__ . '/module/Application/src');
$apiClassLoader->register();
$coreClassLoader = new \Doctrine\Common\ClassLoader('Core', __DIR__ . '/module/Core/src');
$coreClassLoader->register();
$adminClassLoader = new \Doctrine\Common\ClassLoader('Admin', __DIR__ . '/module/Admin/src');
$adminClassLoader->register();
$entityClassLoader = new \Doctrine\Common\ClassLoader('Entities', __DIR__ . '/module/Application/src/Application/Entity');
$entityClassLoader->register();
$proxyClassLoader = new \Doctrine\Common\ClassLoader('EntityProxy', __DIR__ . '/module/Application/src/Application/Entity/Proxies');
$proxyClassLoader->register();
$config = include __DIR__ . '/config/autoload/global.php';
$cache = new $config['doctrine']['driver']['cache'];
$doctrineConfig = new \Doctrine\ORM\Configuration();
$cache = new $config['doctrine']['driver']['cache'];
$doctrineConfig->setQueryCacheImpl($cache);
$doctrineConfig->setProxyDir('/tmp');
$doctrineConfig->setProxyNamespace('EntityProxy');
$doctrineConfig->setAutoGenerateProxyClasses(true);
\Doctrine\Common\Annotations\AnnotationReader::addGlobalIgnoredName('events');
\Doctrine\Common\Annotations\AnnotationRegistry::registerFile(
__DIR__ . '/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php'
);
$driver = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver(
new \Doctrine\Common\Annotations\AnnotationReader(),
array(
__DIR__ . '/module/Application/src/Application/Entity',
)
);
$doctrineConfig->setMetadataDriverImpl($driver);
$doctrineConfig->setMetadataCacheImpl($cache);
$em = \Doctrine\ORM\EntityManager::create(
$config['doctrine']['connection'],
$doctrineConfig
);
/** @var $em \Doctrine\ORM\EntityManager */
$platform = $em->getConnection()->getDatabasePlatform();
$platform->registerDoctrineTypeMapping('enum', 'string');
$helpers = new Symfony\Component\Console\Helper\HelperSet(array(
'db' => new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($em->getConnection()),
'em' => new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($em)
));