8000 fixup · symfony/symfony@d1f6608 · GitHub
[go: up one dir, main page]

Skip to content

Commit d1f6608

Browse files
committed
fixup
1 parent 66d5b2e commit d1f6608

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/Symfony/Bundle/FrameworkBundle/Routing/Loader/XmlFileLoader.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Symfony\Bundle\FrameworkBundle\Controller\RedirectController;
1515
use Symfony\Bundle\FrameworkBundle\Controller\TemplateController;
16+
use Symfony\Component\Config\Util\Exception\XmlParsingException;
1617
use Symfony\Component\Config\Util\XmlUtils;
1718
use Symfony\Component\Routing\Loader\XmlFileLoader as BaseXmlFileLoader;
1819
use Symfony\Component\Routing\RouteCollection;
@@ -26,6 +27,10 @@ class XmlFileLoader extends BaseXmlFileLoader
2627

2728
private const REDEFINED_SCHEME_URI = 'https://symfony.com/schema/routing/routing-1.0.xsd';
2829
private const SCHEME_URI = 'https://symfony.com/schema/routing/framework-routing-1.0.xsd';
30+
private const SCHEMA_LOCATIONS = [
31+
self::REDEFINED_SCHEME_URI => parent::SCHEME_PATH,
32+
self::SCHEME_URI => self::SCHEME_PATH,
33+
];
2934

3035
/** @var \DOMDocument */
3136
private $document;
@@ -35,8 +40,14 @@ class XmlFileLoader extends BaseXmlFileLoader
3540
protected function loadFile(string $file)
3641
{
3742
try {
43+
foreach (self::SCHEMA_LOCATIONS as $uri => $path) {
44+
if (false !== strpos($file, $uri)) {
45+
$file = str_replace([$uri, '\\'], ['file:///'.realpath($path), '/'], $file);
46+
}
47+
}
48+
3849
return $this->document = parent::loadFile($file);
39-
} catch (\Exception $e) {
50+
} catch (XmlParsingException $e) {
4051
if (0 === strpos($e->getMessage(), sprintf('[WARNING 1549] failed to load external entity "%s"', self::REDEFINED_SCHEME_URI))) {
4152
if (!is_writable(self::SCHEME_PATH)) {
4253
throw new \RuntimeException(sprintf('"%s" is not writeable.', self::SCHEME_PATH), 0, $e);
@@ -54,12 +65,6 @@ protected function loadFile(string $file)
5465

5566
return $this->loadFile($file);
5667
}
57-
if (0 === strpos($e->getMessage(), sprintf('[WARNING 1549] failed to load external entity "%s"', self::SCHEME_URI))
58-
// workaround testing on Windows
59-
|| false !== strpos($e->getMessage(), 'C:\projects\symfony\src\Symfony\Bundle\FrameworkBundle\Tests')
60-
) {
61-
return $this->loadFile(str_replace([self::SCHEME_URI, '\\'], ['file:///'.realpath(self::SCHEME_PATH), '/'], $file));
62-
}
6368

6469
throw $e;
6570
} finally {

0 commit comments

Comments
 (0)
0