Commit c98543c1 authored by Benjamin Eberlei's avatar Benjamin Eberlei

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

parent e4d8efa3
...@@ -2,12 +2,15 @@ ...@@ -2,12 +2,15 @@
require_once 'Doctrine/Common/ClassLoader.php'; 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(); $classLoader->register();
$configFile = getcwd() . DIRECTORY_SEPARATOR . 'cli-config.php'; $configFile = getcwd() . DIRECTORY_SEPARATOR . 'cli-config.php';
$configuration = null; $helperSet = null;
if (file_exists($configFile)) { if (file_exists($configFile)) {
if ( ! is_readable($configFile)) { if ( ! is_readable($configFile)) {
trigger_error( trigger_error(
...@@ -17,15 +20,38 @@ if (file_exists($configFile)) { ...@@ -17,15 +20,38 @@ if (file_exists($configFile)) {
require $configFile; require $configFile;
foreach ($GLOBALS as $configCandidate) { foreach ($GLOBALS as $helperSetCandidate) {
if ($configCandidate instanceof \Doctrine\Common\CLI\Configuration) { if ($helperSetCandidate instanceof \Symfony\Components\Console\Helper\HelperSet) {
$configuration = $configCandidate; $helperSet = $helperSetCandidate;
break; break;
} }
} }
} }
$configuration = ($configuration) ?: new \Doctrine\Common\CLI\Configuration(); $helperSet = ($helperSet) ?: new \Symfony\Components\Console\Helper\HelperSet();
$cli = new \Doctrine\Common\CLI\CLIController($configuration); $cli = new \Symfony\Components\Console\Application('Doctrine Command Line Interface', Doctrine\Common\Version::VERSION);
$cli->run($_SERVER['argv']); $cli->setCatchExceptions(true);
\ No newline at end of file $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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment