Fix sqlite regenration command

This commit is contained in:
Romain Neutron
2013-08-08 16:00:36 +02:00
parent caae97ef5a
commit 88f5bfda60
2 changed files with 26 additions and 4 deletions

View File

@@ -4,8 +4,15 @@ namespace Alchemy\Phrasea\Command\Developer;
use Alchemy\Phrasea\Command\Command; use Alchemy\Phrasea\Command\Command;
use Doctrine\ORM\Tools\Setup; use Doctrine\ORM\Tools\Setup;
use Doctrine\ORM\Configuration as ORMConfiguration;
use Doctrine\ORM\Tools\SchemaTool; use Doctrine\ORM\Tools\SchemaTool;
use Doctrine\ORM\EntityManager; use Doctrine\ORM\EntityManager;
use Doctrine\Common\Annotations\AnnotationReader;
use Doctrine\Common\Annotations\AnnotationRegistry;
use Doctrine\Common\Annotations\FileCacheReader;
use Doctrine\Common\EventManager;
use Doctrine\ORM\Mapping\Driver\AnnotationDriver;
use Doctrine\ORM\Mapping\Driver\DriverChain;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Filesystem\Filesystem;
@@ -32,13 +39,28 @@ class RegenerateSqliteDb extends Command
$dbParams = $this->container['phraseanet.configuration']->getTestConnectionParameters(); $dbParams = $this->container['phraseanet.configuration']->getTestConnectionParameters();
$dbParams['path'] = $source; $dbParams['path'] = $source;
$config = Setup::createYAMLMetadataConfiguration(array(__DIR__ . '/../../../../conf.d/Doctrine'), true); $config = new ORMConfiguration();
$em = EntityManager::create($dbParams, $config); AnnotationRegistry::registerFile(
$this->container['root.path'].'/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php'
);
$annotationReader = new AnnotationReader();
$driverChain = new DriverChain();
$annotationDriver = new AnnotationDriver(
$annotationReader,
array($this->container['root.path'].'/lib/Doctrine/Entities')
);
$driverChain->addDriver($annotationDriver, 'Entities');
$config->setAutoGenerateProxyClasses(true);
$config->setMetadataDriverImpl($driverChain);
$config->setProxyDir($this->container['root.path'] . '/lib/Doctrine/Proxies');
$config->setProxyNamespace('Proxies');
$em = EntityManager::create($dbParams, $config, new EventManager());
$metadatas = $em->getMetadataFactory()->getAllMetadata(); $metadatas = $em->getMetadataFactory()->getAllMetadata();
$schemaTool = new SchemaTool($em); $schemaTool = new SchemaTool($em);
$schemaTool->createSchema($metadatas); $schemaTool->createSchema($metadatas);
} catch (\Exception $e) { } catch (\Exception $e) {
$fs->rename($target, $source); $fs->rename($target, $source);

Binary file not shown.