|
16 | 16 | use Symfony\Component\DependencyInjection\ContainerBuilder;
|
17 | 17 | use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
|
18 | 18 | use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
|
| 19 | +use Symfony\Component\Finder\Finder; |
19 | 20 | use Symfony\Component\HttpKernel\DependencyInjection\Extension;
|
20 | 21 |
|
21 | 22 | /**
|
@@ -148,28 +149,31 @@ private function registerAnnotationLoaders(ContainerBuilder $container)
|
148 | 149 | */
|
149 | 150 | private function registerFileLoaders(ContainerBuilder $container)
|
150 | 151 | {
|
151 |
| - $paths = []; |
| 152 | + $prefix = DIRECTORY_SEPARATOR.'Resources'.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR; |
| 153 | + $yamlResources = []; |
| 154 | + $xmlResources = []; |
| 155 | + |
152 | 156 | foreach ($container->getParameter('kernel.bundles') as $bundle) {
|
153 | 157 | $reflectionClass = new \ReflectionClass($bundle);
|
154 |
| - $bundleDirectory = dirname($reflectionClass->getFileName()); |
155 |
| - $glob = $bundleDirectory.DIRECTORY_SEPARATOR.'Resources'.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'resources.{xml,yml}'; |
| 158 | + $configDirectory = dirname($reflectionClass->getFileName()).$prefix; |
| 159 | + $yamlResources = array_merge($yamlResources, glob($configDirectory.'api_resources.{yml,yaml}')); |
156 | 160 |
|
157 |
| - $paths = array_merge($paths, glob($glob, GLOB_BRACE | GLOB_NOSORT)); |
158 |
| - } |
| 161 | + foreach (Finder::create()->files()->in($configDirectory)->path('api_resources')->name('*.{yml,yaml}') as $file) { |
| 162 | + $yamlResources[] = $file->getRealPath(); |
| 163 | + } |
159 | 164 |
|
160 |
| - $yamlPaths = array_filter($paths, function ($v) { |
161 |
| - return preg_match('/\.yml$/', $v); |
162 |
| - }); |
| 165 | + $xmlResources = array_merge($xmlResources, glob($configDirectory.'api_resources.xml')); |
163 | 166 |
|
164 |
| - $xmlPaths = array_filter($paths, function ($v) { |
165 |
| - return preg_match('/\.xml$/', $v); |
166 |
| - }); |
| 167 | + foreach (Finder::create()->files()->in($configDirectory)->path('api_resources')->name('*.xml') as $file) { |
| 168 | + $xmlResources[] = $file->getRealPath(); |
| 169 | + } |
| 170 | + } |
167 | 171 |
|
168 |
| - $container->getDefinition('api_platform.metadata.resource.name_collection_factory.yaml')->replaceArgument(0, $yamlPaths); |
169 |
| - $container->getDefinition('api_platform.metadata.resource.metadata_factory.yaml')->replaceArgument(0, $yamlPaths); |
| 172 | + $container->getDefinition('api_platform.metadata.resource.name_collection_factory.yaml')->replaceArgument(0, $yamlResources); |
| 173 | + $container->getDefinition('api_platform.metadata.resource.metadata_factory.yaml')->replaceArgument(0, $yamlResources); |
170 | 174 |
|
171 |
| - $container->getDefinition('api_platform.metadata.resource.name_collection_factory.xml')->replaceArgument(0, $xmlPaths); |
172 |
| - $container->getDefinition('api_platform.metadata.resource.metadata_factory.xml')->replaceArgument(0, $xmlPaths); |
| 175 | + $container->getDefinition('api_platform.metadata.resource.name_collection_factory.xml')->replaceArgument(0, $xmlResources); |
| 176 | + $container->getDefinition('api_platform.metadata.resource.metadata_factory.xml')->replaceArgument(0, $xmlResources); |
173 | 177 | }
|
174 | 178 |
|
175 | 179 | /**
|
|
0 commit comments