Преглед на файлове

[WebBundle][DoctrineBundle] Use backslashes in namespaces, not slashes.

The registerBundleDirs method in the kernel returns array(namespace => dir, ...).
In some places dirname() is used to separate a namespace from the classname. The
resulting value contains slashes rather than backslashes, causing look ups in the
bundle dirs array to fail.

I assume this was not noticed so far because it requires that you use one of the
features making this mistake with a bundle inside a subnamespace, as top level
namespaces will not contain a backslash anyway.
Nils Adermann преди 15 години
родител
ревизия
68af3ebfb7

+ 2 - 2
src/Symfony/Framework/DoctrineBundle/Bundle.php

@@ -36,7 +36,7 @@ class Bundle extends BaseBundle
     foreach ($container->getParameter('kernel.bundles') as $className)
     {
       $tmp = dirname(str_replace('\\', '/', $className));
-      $namespace = dirname($tmp);
+      $namespace = str_replace('/', '\\', dirname($tmp));
       $class = basename($tmp);
 
       if (isset($bundleDirs[$namespace]))
@@ -54,4 +54,4 @@ class Bundle extends BaseBundle
     $container->setParameter('doctrine.orm.metadata_driver_impl.dirs', $metadataDirs);
     $container->setParameter('doctrine.entity_dirs', $entityDirs);
   }
-}
+}

+ 2 - 2
src/Symfony/Framework/DoctrineBundle/Command/GenerateProxiesDoctrineCommand.php

@@ -48,7 +48,7 @@ class GenerateProxiesDoctrineCommand extends DoctrineCommand
     foreach ($this->container->getKernelService()->getBundles() as $bundle)
     {
       $tmp = dirname(str_replace('\\', '/', get_class($bundle)));
-      $namespace = dirname($tmp);
+      $namespace = str_replace('/', '\\', dirname($tmp));
       $class = basename($tmp);
 
       if (isset($bundleDirs[$namespace]) && is_dir($dir = $bundleDirs[$namespace].'/'.$class.'/Entities'))
@@ -67,4 +67,4 @@ class GenerateProxiesDoctrineCommand extends DoctrineCommand
       $this->runDoctrineCliTask('orm:generate-proxies', array('class-dir' => $dir));
     }
   }
-}
+}

+ 2 - 2
src/Symfony/Framework/DoctrineBundle/Command/LoadDataFixturesDoctrineCommand.php

@@ -88,7 +88,7 @@ class LoadDataFixturesDoctrineCommand extends DoctrineCommand
       foreach ($this->container->getKernelService()->getBundles() as $bundle)
       {
         $tmp = dirname(str_replace('\\', '/', get_class($bundle)));
-        $namespace = dirname($tmp);
+        $namespace = str_replace('/', '\\', dirname($tmp));
         $class = basename($tmp);
 
         if (isset($bundleDirs[$namespace]) && is_dir($dir = $bundleDirs[$namespace].'/'.$class.'/Resources/data/fixtures/doctrine'))
@@ -154,4 +154,4 @@ class LoadDataFixturesDoctrineCommand extends DoctrineCommand
 
     return $calc->getCommitOrder();
   }
-}
+}

+ 1 - 1
src/Symfony/Framework/WebBundle/Command/AssetsInstallCommand.php

@@ -56,7 +56,7 @@ class AssetsInstallCommand extends Command
     foreach ($this->container->getKernelService()->getBundles() as $bundle)
     {
       $tmp = dirname(str_replace('\\', '/', get_class($bundle)));
-      $namespace = dirname($tmp);
+      $namespace = str_replace('/', '\\', dirname($tmp));
       $class = basename($tmp);
 
       if (isset($dirs[$namespace]) && is_dir($originDir = $dirs[$namespace].'/'.$class.'/Resources/public'))

+ 1 - 1
src/Symfony/Framework/WebBundle/Command/InitBundleCommand.php

@@ -54,7 +54,7 @@ class InitBundleCommand extends Command
     $dirs = $this->container->getKernelService()->getBundleDirs();
 
     $tmp = str_replace('\\', '/', $namespace);
-    $namespace = dirname($tmp);
+    $namespace = str_replace('/', '\\', dirname($tmp));
     $bundle = basename($tmp);
 
     if (!isset($dirs[$namespace]))