Skip to content

Commit 8e30e66

Browse files
authored
Merge pull request #1722 from Nek-/fix/bc-break-sf-flex
Fix wrong automatic configuration for Sf flex
2 parents 615dc88 + 6bffa90 commit 8e30e66

File tree

2 files changed

+6
-21
lines changed

2 files changed

+6
-21
lines changed

features/main/configurable.feature

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ Feature: Configurable resource CRUD
4444
}
4545
"""
4646

47+
@dropSchema
4748
Scenario: Retrieve the ConfigDummy resource
4849
When I send a "GET" request to "/fileconfigdummies/1"
4950
Then the response status code should be 200
@@ -60,20 +61,3 @@ Feature: Configurable resource CRUD
6061
"foo": "Foo"
6162
}
6263
"""
63-
64-
@dropSchema
65-
Scenario: Entities can be configured using a Flex-like directory structure
66-
When I send a "GET" request to "/flex_configs"
67-
Then the response status code should be 200
68-
And the response should be in JSON
69-
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
70-
And the JSON should be equal to:
71-
"""
72-
{
73-
"@context": "/contexts/FlexConfig",
74-
"@id": "/flex_configs",
75-
"@type": "hydra:Collection",
76-
"hydra:member": [],
77-
"hydra:totalItems": 0
78-
}
79-
"""

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -246,13 +246,14 @@ private function getBundlesResourcesPaths(ContainerBuilder $container): array
246246

247247
private function getResourcesToWatch(ContainerBuilder $container, array $resourcesPaths): array
248248
{
249-
// Flex structure
249+
$paths = array_unique(array_merge($resourcesPaths, $this->getBundlesResourcesPaths($container)));
250+
251+
// Flex structure (only if nothing specified)
250252
$projectDir = $container->getParameter('kernel.project_dir');
251-
if (is_dir($dir = "$projectDir/config/api_platform")) {
252-
$resourcesPaths[] = $dir;
253+
if (!$paths && is_dir($dir = "$projectDir/config/api_platform")) {
254+
$paths = [$dir];
253255
}
254256

255-
$paths = array_unique(array_merge($resourcesPaths, $this->getBundlesResourcesPaths($container)));
256257
$resources = ['yml' => [], 'xml' => [], 'dir' => []];
257258

258259
foreach ($paths as $path) {

0 commit comments

Comments
 (0)