-
Notifications
You must be signed in to change notification settings - Fork 7
/
orm
executable file
·28 lines (20 loc) · 905 Bytes
/
orm
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
#!/usr/bin/env php
<?php
if (php_sapi_name() != 'cli') {
throw new RuntimeException("This script can only be called from the command line.");
}
// make sure we are in the correct directory
chdir(__DIR__);
require 'bootstrap.php';
use Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper;
$application = ConsoleRunner::getApplication();
/* @var $cli \Symfony\Component\Console\Application */
$cli = $application->getServiceManager()->get('doctrine.cli');
// If we've overridden the entity manager via env var, inject the new one
$entityManagerName = getenv('EM_ALIAS') ?: 'orm_default';
$entityManagerName = "doctrine.entitymanager.". $entityManagerName;
if ( $application->getServiceManager()->has($entityManagerName) ) {
$emHelper = new EntityManagerHelper($application->getServiceManager()->get($entityManagerName));
$cli->getHelperSet()->set($emHelper, 'em');
}
exit($cli->run());