bug #34024 [Routing] fix route loading with wildcard, but dir or file is empty (gseidel)
This PR was merged into the 4.3 branch.
Discussion
----------
[Routing] fix route loading with wildcard, but dir or file is empty
| Q | A
| ------------- | ---
| Branch? | 4.3
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | no ticket i see so far
| License | MIT
In my route config i have something like:
```yaml
empty_wildcard:
resource: ../controller/empty_wildcard/*
prefix: /empty_wildcard
```
But ``empty_wildcard`` is empty or has no route configured.
So i had this error:
``Call to a member function addPrefix() on null``
This PR take care if no route is configured, there will be no error.
Commits
-------
217058b475
[Routing] fix route loading with wildcard, but dir or file is empty
This commit is contained in:
parent
a054d88830
commit
a54ecb0fae
@ -39,7 +39,8 @@ class RoutingConfigurator
|
|||||||
final public function import($resource, $type = null, $ignoreErrors = false)
|
final public function import($resource, $type = null, $ignoreErrors = false)
|
||||||
{
|
{
|
||||||
$this->loader->setCurrentDir(\dirname($this->path));
|
$this->loader->setCurrentDir(\dirname($this->path));
|
||||||
$imported = $this->loader->import($resource, $type, $ignoreErrors, $this->file);
|
$imported = $this->loader->import($resource, $type, $ignoreErrors, $this->file) ?: [];
|
||||||
|
|
||||||
if (!\is_array($imported)) {
|
if (!\is_array($imported)) {
|
||||||
return new ImportConfigurator($this->collection, $imported);
|
return new ImportConfigurator($this->collection, $imported);
|
||||||
}
|
}
|
||||||
|
@ -146,7 +146,8 @@ class XmlFileLoader extends FileLoader
|
|||||||
|
|
||||||
$this->setCurrentDir(\dirname($path));
|
$this->setCurrentDir(\dirname($path));
|
||||||
|
|
||||||
$imported = $this->import($resource, ('' !== $type ? $type : null), false, $file);
|
/** @var RouteCollection[] $imported */
|
||||||
|
$imported = $this->import($resource, ('' !== $type ? $type : null), false, $file) ?: [];
|
||||||
|
|
||||||
if (!\is_array($imported)) {
|
if (!\is_array($imported)) {
|
||||||
$imported = [$imported];
|
$imported = [$imported];
|
||||||
|
@ -158,7 +158,7 @@ class YamlFileLoader extends FileLoader
|
|||||||
|
|
||||||
$this->setCurrentDir(\dirname($path));
|
$this->setCurrentDir(\dirname($path));
|
||||||
|
|
||||||
$imported = $this->import($config['resource'], $type, false, $file);
|
$imported = $this->import($config['resource'], $type, false, $file) ?: [];
|
||||||
|
|
||||||
if (!\is_array($imported)) {
|
if (!\is_array($imported)) {
|
||||||
$imported = [$imported];
|
$imported = [$imported];
|
||||||
|
Reference in New Issue
Block a user