bug #11232 [Routing] Fixes fatal errors with object resources in AnnotationDirectoryLoader::supports (Tischoi)
This PR was submitted for the master branch but it was merged into the 2.3 branch instead (closes #11232).
Discussion
----------
[Routing] Fixes fatal errors with object resources in AnnotationDirectoryLoader::supports
| Q | A
| ------------- | ---
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets |
| License | MIT
| Doc PR |
Fixes fatal errors that occur in the supports method with objects that aren't string convertible / don't implement ArrayAccess. This is mostly a problem because some locators try to access a specific character in the resource name.
Since the resource is checked if it's a string either way, it's the most simple solution to just move that check a bit ahead.
Commits
-------
5e80585
Update AnnotationDirectoryLoader.php
This commit is contained in:
commit
a0a97d7521
@ -66,12 +66,16 @@ class AnnotationDirectoryLoader extends AnnotationFileLoader
|
|||||||
*/
|
*/
|
||||||
public function supports($resource, $type = null)
|
public function supports($resource, $type = null)
|
||||||
{
|
{
|
||||||
|
if (!is_string($resource)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$path = $this->locator->locate($resource);
|
$path = $this->locator->locate($resource);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return is_string($resource) && is_dir($path) && (!$type || 'annotation' === $type);
|
return is_dir($path) && (!$type || 'annotation' === $type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user