Files
Phraseanet/bin/doctrine
2012-10-04 15:43:36 +02:00

77 lines
2.5 KiB
PHP
Executable File

#!/usr/bin/env php
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2010 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
use Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper;
use Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper;
use Alchemy\Phrasea\CLI;
// DBAL Commands
use Doctrine\DBAL\Tools\Console\Command\RunSqlCommand;
use Doctrine\DBAL\Tools\Console\Command\ImportCommand;
// ORM Commands
use Doctrine\ORM\Tools\Console\Command\ClearCache\MetadataCommand;
use Doctrine\ORM\Tools\Console\Command\ClearCache\ResultCommand;
use Doctrine\ORM\Tools\Console\Command\ClearCache\QueryCommand;
use Doctrine\ORM\Tools\Console\Command\SchemaTool\CreateCommand;
use Doctrine\ORM\Tools\Console\Command\SchemaTool\UpdateCommand;
use Doctrine\ORM\Tools\Console\Command\SchemaTool\DropCommand;
use Doctrine\ORM\Tools\Console\Command\EnsureProductionSettingsCommand;
use Doctrine\ORM\Tools\Console\Command\ConvertDoctrine1SchemaCommand;
use Doctrine\ORM\Tools\Console\Command\GenerateRepositoriesCommand;
use Doctrine\ORM\Tools\Console\Command\GenerateEntitiesCommand;
use Doctrine\ORM\Tools\Console\Command\GenerateProxiesCommand;
use Doctrine\ORM\Tools\Console\Command\ConvertMappingCommand;
use Doctrine\ORM\Tools\Console\Command\RunDqlCommand;
use Doctrine\ORM\Tools\Console\Command\ValidateSchemaCommand;
require_once dirname(__FILE__) . '/../lib/bootstrap.php';
try {
$cli = new CLI("Phraseanet Doctrine Console");
$helpers = array(
'db' => new ConnectionHelper($cli['EM']->getConnection()),
'em' => new EntityManagerHelper($cli['EM'])
);
$helperSet = $cli['console']->getHelperSet();
foreach ($helpers as $name => $helper) {
$helperSet->set($helper, $name);
}
$cli['console']->addCommands(array(
// DBAL Commands
new RunSqlCommand(),
new ImportCommand(),
// ORM Commands
new MetadataCommand(),
new ResultCommand(),
new QueryCommand(),
new CreateCommand(),
new UpdateCommand(),
new DropCommand(),
new EnsureProductionSettingsCommand(),
new ConvertDoctrine1SchemaCommand(),
new GenerateRepositoriesCommand(),
new GenerateEntitiesCommand(),
new GenerateProxiesCommand(),
new ConvertMappingCommand(),
new RunDqlCommand(),
new ValidateSchemaCommand(),
));
$cli->runCLI();
} catch (Exception $e) {
echo "an error occured : " . $e->getMessage();
exit(1);
}
exit(0);