[DependencyInjection] fixed XSD validation local path locations for extensions
This commit is contained in:
parent
5d8529740a
commit
4735bf88a3
@ -45,6 +45,13 @@ interface LoaderExtensionInterface
|
|||||||
*/
|
*/
|
||||||
public function getNamespace();
|
public function getNamespace();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the base path for the XSD files.
|
||||||
|
*
|
||||||
|
* @return string The XSD base path
|
||||||
|
*/
|
||||||
|
public function getXsdValidationBasePath();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the recommanded alias to use in XML.
|
* Returns the recommanded alias to use in XML.
|
||||||
*
|
*
|
||||||
|
@ -258,7 +258,17 @@ class XmlFileLoader extends FileLoader
|
|||||||
$items = preg_split('/\s+/', $element);
|
$items = preg_split('/\s+/', $element);
|
||||||
for ($i = 0, $nb = count($items); $i < $nb; $i += 2)
|
for ($i = 0, $nb = count($items); $i < $nb; $i += 2)
|
||||||
{
|
{
|
||||||
$schemaLocations[$items[$i]] = str_replace('http://www.symfony-project.org/', str_replace('\\', '/', __DIR__).'/', $items[$i + 1]);
|
if ($extension = static::getExtension($items[$i]))
|
||||||
|
{
|
||||||
|
$path = str_replace('http://www.symfony-project.org/', str_replace('\\', '/', $extension->getXsdValidationBasePath()).'/', $items[$i + 1]);
|
||||||
|
|
||||||
|
if (!file_exists($path))
|
||||||
|
{
|
||||||
|
throw new \RuntimeException(sprintf('Extension "%s" references a non-existent XSD file "%s"', get_class($extension), $path));
|
||||||
|
}
|
||||||
|
|
||||||
|
$schemaLocations[$items[$i]] = $path;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user