From c98543c1efc3ddd8ee80cf62b56775922cf69173 Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Fri, 9 Apr 2010 15:34:53 +0200 Subject: [PATCH] Fix bin/doctrine.php global doctrine binary to work with Symfony components --- bin/doctrine.php | 42 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 8 deletions(-) diff --git a/bin/doctrine.php b/bin/doctrine.php index cd507f6c7..b1a29efeb 100644 --- a/bin/doctrine.php +++ b/bin/doctrine.php @@ -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']); \ No newline at end of file +$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(); \ No newline at end of file