Skip to content

Commit

Permalink
[DoctrineBundle] added new DisconnectedMetadataFactory class that is …
Browse files Browse the repository at this point in the history
…now used in the doctrine:generate:entities command instead of the MetadataFactory class.
  • Loading branch information
Hugo Hamon committed Jun 10, 2011
1 parent 25c3fee commit ce3839a
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 5 deletions.
Expand Up @@ -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
Expand Down Expand Up @@ -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'));
Expand Down
@@ -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';
}
}
12 changes: 9 additions & 3 deletions src/Symfony/Bundle/DoctrineBundle/Mapping/MetadataFactory.php
Expand Up @@ -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 <fabien@symfony.com>
*/
Expand Down Expand Up @@ -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;
Expand All @@ -168,4 +169,9 @@ private function getAllMetadata()

return $metadata;
}

protected function getClassMetadataFactoryClass()
{
return '\\Doctrine\\ORM\\Mapping\\ClassMetadataFactory';
}
}

0 comments on commit ce3839a

Please sign in to comment.