[Routing] fixed imports from the current directory
This commit is contained in:
parent
507da2a1ab
commit
8649debb06
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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)));
|
||||
}
|
||||
|
@ -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:
|
||||
|
@ -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);
|
||||
|
Reference in New Issue
Block a user