[DoctrineBundle] added new DisconnectedMetadataFactory class that is now used in the doctrine:generate:entities command instead of the MetadataFactory class.

This commit is contained in:
Hugo Hamon 2011-06-10 14:24:31 +02:00
parent 25c3fee1f2
commit ce3839a3ea
3 changed files with 36 additions and 5 deletions

View File

@ -16,7 +16,7 @@ use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Doctrine\ORM\Tools\EntityRepositoryGenerator;
use Symfony\Bundle\DoctrineBundle\Mapping\MetadataFactory;
use Symfony\Bundle\DoctrineBundle\Mapping\DisconnectedMetadataFactory;
/**
* Generate entity classes from mapping information
@ -71,7 +71,7 @@ EOT
protected function execute(InputInterface $input, OutputInterface $output)
{
$manager = new MetadataFactory($this->container->get('doctrine'));
$manager = new DisconnectedMetadataFactory($this->container->get('doctrine'));
try {
$bundle = $this->getApplication()->getKernel()->getBundle($input->getArgument('name'));

View File

@ -0,0 +1,25 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Bundle\DoctrineBundle\Mapping;
/**
*
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class DisconnectedMetadataFactory extends MetadataFactory
{
protected function getClassMetadataFactoryClass()
{
return '\\Doctrine\\ORM\Tools\\DisconnectedClassMetadataFactory';
}
}

View File

@ -17,10 +17,10 @@ use Doctrine\ORM\Tools\EntityRepositoryGenerator;
use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\ORM\Mapping\ClassMetadataInfo;
use Doctrine\ORM\ORMException;
use Doctrine\ORM\Tools\DisconnectedClassMetadataFactory;
/**
*
* This class provides methods to access Doctrine entity class metadata for a
* given bundle, namespace or entity class.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
@ -159,7 +159,8 @@ class MetadataFactory
{
$metadata = array();
foreach ($this->registry->getEntityManagers() as $em) {
$cmf = new DisconnectedClassMetadataFactory();
$class = $this->getClassMetadataFactoryClass();
$cmf = new $class();
$cmf->setEntityManager($em);
foreach ($cmf->getAllMetadata() as $m) {
$metadata[] = $m;
@ -168,4 +169,9 @@ class MetadataFactory
return $metadata;
}
protected function getClassMetadataFactoryClass()
{
return '\\Doctrine\\ORM\\Mapping\\ClassMetadataFactory';
}
}