Переглянути джерело

Merge remote branch 'hhamon/doctrine_metadatafactory_fix'

* hhamon/doctrine_metadatafactory_fix:
  [DoctrineBundle] fixed missing backslashe.
  [DoctrineBundle] simplified getClassMetadataFactoryClass() method in both DisconnectedMetadataFactory and MetadataFactory classes.
  [DoctrineBundle] added new DisconnectedMetadataFactory class that is now used in the doctrine:generate:entities command instead of the MetadataFactory class.
Fabien Potencier 14 роки тому
батько
коміт
8e6d287614

+ 2 - 2
src/Symfony/Bundle/DoctrineBundle/Command/GenerateEntitiesDoctrineCommand.php

@@ -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'));

+ 25 - 0
src/Symfony/Bundle/DoctrineBundle/Mapping/DisconnectedMetadataFactory.php

@@ -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';
+    }
+}

+ 9 - 3
src/Symfony/Bundle/DoctrineBundle/Mapping/MetadataFactory.php

@@ -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';
+    }
 }