diff --git a/src/Bridge/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php b/src/Bridge/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php index b74598fbc53..5ac1a68cf78 100644 --- a/src/Bridge/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php +++ b/src/Bridge/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php @@ -149,23 +149,23 @@ private function registerAnnotationLoaders(ContainerBuilder $container) */ private function registerFileLoaders(ContainerBuilder $container) { - $prefix = DIRECTORY_SEPARATOR.'Resources'.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR; $yamlResources = []; $xmlResources = []; foreach ($container->getParameter('kernel.bundles') as $bundle) { $reflectionClass = new \ReflectionClass($bundle); - $configDirectory = dirname($reflectionClass->getFileName()).$prefix; - $yamlResources = array_merge($yamlResources, glob($configDirectory.'api_resources.{yml,yaml}')); - - foreach (Finder::create()->files()->in($configDirectory)->path('api_resources')->name('*.{yml,yaml}') as $file) { - $yamlResources[] = $file->getRealPath(); - } - - $xmlResources = array_merge($xmlResources, glob($configDirectory.'api_resources.xml')); - - foreach (Finder::create()->files()->in($configDirectory)->path('api_resources')->name('*.xml') as $file) { - $xmlResources[] = $file->getRealPath(); + $configDirectory = dirname($reflectionClass->getFileName()).'/Resources/config/'; + + try { + foreach (Finder::create()->files()->in($configDirectory)->path('api_resources')->name('*.{yml,yaml,xml}') as $file) { + if ('xml' === $file->getExtension()) { + $xmlResources[] = $file->getRealPath(); + } else { + $yamlResources[] = $file->getRealPath(); + } + } + } catch (\InvalidArgumentException $e) { + // Ignore invalid paths } }