Skip to content

Commit 3699d45

Browse files
gseidelnicolas-grekas
authored andcommitted
[Routing] fix route loading with wildcard, but dir or file is empty
1 parent 3b174ef commit 3699d45

File tree

5 files changed

+8
-3
lines changed

5 files changed

+8
-3
lines changed

Loader/Configurator/RoutingConfigurator.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ public function __construct(RouteCollection $collection, PhpFileLoader $loader,
3939
final public function import($resource, $type = null, $ignoreErrors = false)
4040
{
4141
$this->loader->setCurrentDir(\dirname($this->path));
42-
$imported = $this->loader->import($resource, $type, $ignoreErrors, $this->file);
42+
$imported = $this->loader->import($resource, $type, $ignoreErrors, $this->file) ?? [];
43+
4344
if (!\is_array($imported)) {
4445
return new ImportConfigurator($this->collection, $imported);
4546
}

Loader/XmlFileLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ protected function parseImport(RouteCollection $collection, \DOMElement $node, $
169169
$this->setCurrentDir(\dirname($path));
170170

171171
/** @var RouteCollection[] $imported */
172-
$imported = $this->import($resource, ('' !== $type ? $type : null), false, $file);
172+
$imported = $this->import($resource, ('' !== $type ? $type : null), false, $file) ?? [];
173173

174174
if (!\is_array($imported)) {
175175
$imported = [$imported];

Loader/YamlFileLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ protected function parseImport(RouteCollection $collection, array $config, $path
187187

188188
$this->setCurrentDir(\dirname($path));
189189

190-
$imported = $this->import($config['resource'], $type, false, $file);
190+
$imported = $this->import($config['resource'], $type, false, $file) ?? [];
191191

192192
if (!\is_array($imported)) {
193193
$imported = [$imported];

Tests/Fixtures/controller/empty_wildcard/.gitignore

Whitespace-only changes.

Tests/Fixtures/import_with_name_prefix/routing.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,7 @@ api:
55
resource: ../controller/routing.yml
66
name_prefix: api_
77
prefix: /api
8+
9+
empty_wildcard:
10+
resource: ../controller/empty_wildcard/*
11+
prefix: /empty_wildcard

0 commit comments

Comments
 (0)