Skip to content

Commit e1a0312

Browse files
committed
Fix XML/YAML config loading
1 parent cde69f8 commit e1a0312

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/Bridge/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -149,23 +149,23 @@ private function registerAnnotationLoaders(ContainerBuilder $container)
149149
*/
150150
private function registerFileLoaders(ContainerBuilder $container)
151151
{
152-
$prefix = DIRECTORY_SEPARATOR.'Resources'.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR;
153152
$yamlResources = [];
154153
$xmlResources = [];
155154

156155
foreach ($container->getParameter('kernel.bundles') as $bundle) {
157156
$reflectionClass = new \ReflectionClass($bundle);
158-
$configDirectory = dirname($reflectionClass->getFileName()).$prefix;
159-
$yamlResources = array_merge($yamlResources, glob($configDirectory.'api_resources.{yml,yaml}'));
160-
161-
foreach (Finder::create()->files()->in($configDirectory)->path('api_resources')->name('*.{yml,yaml}') as $file) {
162-
$yamlResources[] = $file->getRealPath();
163-
}
164-
165-
$xmlResources = array_merge($xmlResources, glob($configDirectory.'api_resources.xml'));
166-
167-
foreach (Finder::create()->files()->in($configDirectory)->path('api_resources')->name('*.xml') as $file) {
168-
$xmlResources[] = $file->getRealPath();
157+
$configDirectory = dirname($reflectionClass->getFileName()).'/Resources/config/';
158+
159+
try {
160+
foreach (Finder::create()->files()->in($configDirectory)->path('api_resources')->name('*.{yml,yaml,xml}') as $file) {
161+
if ('xml' === $file->getExtension()) {
162+
$xmlResources[] = $file->getRealPath();
163+
} else {
164+
$yamlResources[] = $file->getRealPath();
165+
}
166+
}
167+
} catch (\InvalidArgumentException $e) {
168+
// Ignore invalid paths
169169
}
170170
}
171171

0 commit comments

Comments
 (0)