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

[Routing] fixed imports from the current directory

Fabien Potencier 14 роки тому
батько
коміт
8649debb06

+ 2 - 2
src/Symfony/Bundle/FrameworkBundle/Routing/FileLocator.php

@@ -39,12 +39,12 @@ class FileLocator extends BaseFileLocator
     /**
      * {@inheritdoc}
      */
-    public function locate($file)
+    public function locate($file, $currentPath = null)
     {
         if ('@' === $file[0]) {
             return $this->kernel->locateResource($file);
         }
 
-        return parent::locate($file);
+        return parent::locate($file, $currentPath);
     }
 }

+ 4 - 3
src/Symfony/Component/Routing/Loader/FileLocator.php

@@ -36,15 +36,16 @@ class FileLocator
     /**
      * Returns a full path for a given file.
      *
-     * @param string $file A file path
+     * @param string $file        A file path
+     * @param string $currentPath The current path
      *
      * @return string The full path for the file
      *
      * @throws \InvalidArgumentException When file is not found
      */
-    public function locate($file)
+    public function locate($file, $currentPath = null)
     {
-        $path = $this->getAbsolutePath($file);
+        $path = $this->getAbsolutePath($file, $currentPath);
         if (!file_exists($path)) {
             throw new \InvalidArgumentException(sprintf('The file "%s" does not exist (in: %s).', $file, implode(', ', $this->paths)));
         }

+ 1 - 1
src/Symfony/Component/Routing/Loader/XmlFileLoader.php

@@ -56,7 +56,7 @@ class XmlFileLoader extends FileLoader
                     $type = (string) $node->getAttribute('type');
                     $prefix = (string) $node->getAttribute('prefix');
                     $this->currentDir = dirname($path);
-                    $file = $this->locator->locate($resource);
+                    $file = $this->locator->locate($resource, $this->currentDir);
                     $collection->addCollection($this->import($file, $type), $prefix);
                     break;
                 default:

+ 1 - 1
src/Symfony/Component/Routing/Loader/YamlFileLoader.php

@@ -57,7 +57,7 @@ class YamlFileLoader extends FileLoader
                 $type = isset($config['type']) ? $config['type'] : null;
                 $prefix = isset($config['prefix']) ? $config['prefix'] : null;
                 $this->currentDir = dirname($path);
-                $file = $this->locator->locate($config['resource']);
+                $file = $this->locator->locate($config['resource'], $this->currentDir);
                 $collection->addCollection($this->import($file, $type), $prefix);
             } elseif (isset($config['pattern'])) {
                 $this->parseRoute($collection, $name, $config, $path);