1
0
mirror of synced 2024-12-05 03:06:05 +03:00

Fix bin/doctrine.php global doctrine binary to work with Symfony components

This commit is contained in:
Benjamin Eberlei 2010-04-09 15:34:53 +02:00
parent e4d8efa394
commit c98543c1ef

View File

@ -2,12 +2,15 @@
require_once 'Doctrine/Common/ClassLoader.php';
$classLoader = new \Doctrine\Common\ClassLoader('Doctrine');
$classLoader = new \Doctrine\Common\ClassLoader('Doctrine', __DIR__ . '/../lib');
$classLoader->register();
$classLoader = new \Doctrine\Common\ClassLoader('Symfony', __DIR__ . '/../lib/vendor');
$classLoader->register();
$configFile = getcwd() . DIRECTORY_SEPARATOR . 'cli-config.php';
$configuration = null;
$helperSet = null;
if (file_exists($configFile)) {
if ( ! is_readable($configFile)) {
trigger_error(
@ -17,15 +20,38 @@ if (file_exists($configFile)) {
require $configFile;
foreach ($GLOBALS as $configCandidate) {
if ($configCandidate instanceof \Doctrine\Common\CLI\Configuration) {
$configuration = $configCandidate;
foreach ($GLOBALS as $helperSetCandidate) {
if ($helperSetCandidate instanceof \Symfony\Components\Console\Helper\HelperSet) {
$helperSet = $helperSetCandidate;
break;
}
}
}
$configuration = ($configuration) ?: new \Doctrine\Common\CLI\Configuration();
$helperSet = ($helperSet) ?: new \Symfony\Components\Console\Helper\HelperSet();
$cli = new \Doctrine\Common\CLI\CLIController($configuration);
$cli->run($_SERVER['argv']);
$cli = new \Symfony\Components\Console\Application('Doctrine Command Line Interface', Doctrine\Common\Version::VERSION);
$cli->setCatchExceptions(true);
$cli->setHelperSet($helperSet);
$cli->addCommands(array(
// DBAL Commands
new \Doctrine\DBAL\Tools\Console\Command\RunSqlCommand(),
new \Doctrine\DBAL\Tools\Console\Command\ImportCommand(),
// ORM Commands
new \Doctrine\ORM\Tools\Console\Command\ClearCache\MetadataCommand(),
new \Doctrine\ORM\Tools\Console\Command\ClearCache\ResultCommand(),
new \Doctrine\ORM\Tools\Console\Command\ClearCache\QueryCommand(),
new \Doctrine\ORM\Tools\Console\Command\SchemaTool\CreateCommand(),
new \Doctrine\ORM\Tools\Console\Command\SchemaTool\UpdateCommand(),
new \Doctrine\ORM\Tools\Console\Command\SchemaTool\DropCommand(),
new \Doctrine\ORM\Tools\Console\Command\EnsureProductionSettingsCommand(),
new \Doctrine\ORM\Tools\Console\Command\ConvertDoctrine1SchemaCommand(),
new \Doctrine\ORM\Tools\Console\Command\GenerateRepositoriesCommand(),
new \Doctrine\ORM\Tools\Console\Command\GenerateEntitiesCommand(),
new \Doctrine\ORM\Tools\Console\Command\GenerateProxiesCommand(),
new \Doctrine\ORM\Tools\Console\Command\ConvertMappingCommand(),
new \Doctrine\ORM\Tools\Console\Command\RunDqlCommand(),
));
$cli->run();