Explorar o código

[DoctrineBundle] simplified code

Fabien Potencier %!s(int64=14) %!d(string=hai) anos
pai
achega
1bc8071d4e

+ 0 - 18
src/Symfony/Bundle/DoctrineBundle/Command/DoctrineCommand.php

@@ -139,24 +139,6 @@ abstract class DoctrineCommand extends Command
         return $bundleMetadatas;
     }
 
-    protected function findBundle($bundleName)
-    {
-        $foundBundle = false;
-        foreach ($this->getApplication()->getKernel()->getBundles() as $bundle) {
-            /* @var $bundle Bundle */
-            if (strtolower($bundleName) == strtolower($bundle->getName())) {
-                $foundBundle = $bundle;
-                break;
-            }
-        }
-
-        if (!$foundBundle) {
-            throw new \InvalidArgumentException("No bundle " . $bundleName . " was found.");
-        }
-
-        return $foundBundle;
-    }
-
     /**
      * Transform classname to a path $foundBundle substract it to get the destination
      *

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

@@ -53,7 +53,7 @@ EOT
         $bundleName = $input->getArgument('bundle');
         $filterEntity = $input->getOption('entity');
 
-        $foundBundle = $this->findBundle($bundleName);
+        $foundBundle = $this->getApplication()->getKernel()->getBundle($bundleName);
 
         if ($metadatas = $this->getBundleMetadatas($foundBundle)) {
             $output->writeln(sprintf('Generating entities for "<info>%s</info>"', $foundBundle->getName()));

+ 1 - 1
src/Symfony/Bundle/DoctrineBundle/Command/GenerateRepositoriesDoctrineCommand.php

@@ -46,7 +46,7 @@ EOT
         $bundleName = $input->getArgument('bundle');
         $filterEntity = $input->getOption('entity');
 
-        $foundBundle = $this->findBundle($bundleName);
+        $foundBundle = $this->getApplication()->getKernel()->getBundle($bundleName);
 
         if ($metadatas = $this->getBundleMetadatas($foundBundle)) {
             $output->writeln(sprintf('Generating entity repositories for "<info>%s</info>"', $foundBundle->getName()));