diff --git a/src/Symfony/Bundle/DoctrineBundle/Command/GenerateEntitiesDoctrineCommand.php b/src/Symfony/Bundle/DoctrineBundle/Command/GenerateEntitiesDoctrineCommand.php index 2585dcb66737..c5307cae8dd7 100644 --- a/src/Symfony/Bundle/DoctrineBundle/Command/GenerateEntitiesDoctrineCommand.php +++ b/src/Symfony/Bundle/DoctrineBundle/Command/GenerateEntitiesDoctrineCommand.php @@ -16,7 +16,7 @@ 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 @@ protected function configure() 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')); diff --git a/src/Symfony/Bundle/DoctrineBundle/Mapping/DisconnectedMetadataFactory.php b/src/Symfony/Bundle/DoctrineBundle/Mapping/DisconnectedMetadataFactory.php new file mode 100644 index 000000000000..6adb6b47a799 --- /dev/null +++ b/src/Symfony/Bundle/DoctrineBundle/Mapping/DisconnectedMetadataFactory.php @@ -0,0 +1,25 @@ + + * + * 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 + */ +class DisconnectedMetadataFactory extends MetadataFactory +{ + protected function getClassMetadataFactoryClass() + { + return '\\Doctrine\\ORM\Tools\\DisconnectedClassMetadataFactory'; + } +} \ No newline at end of file diff --git a/src/Symfony/Bundle/DoctrineBundle/Mapping/MetadataFactory.php b/src/Symfony/Bundle/DoctrineBundle/Mapping/MetadataFactory.php index 7697dc4e18d4..3dc1e85143b0 100644 --- a/src/Symfony/Bundle/DoctrineBundle/Mapping/MetadataFactory.php +++ b/src/Symfony/Bundle/DoctrineBundle/Mapping/MetadataFactory.php @@ -17,10 +17,10 @@ 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 */ @@ -159,7 +159,8 @@ private function getAllMetadata() { $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 @@ private function getAllMetadata() return $metadata; } + + protected function getClassMetadataFactoryClass() + { + return '\\Doctrine\\ORM\\Mapping\\ClassMetadataFactory'; + } }