Skip to content

Commit dabbcb6

Browse files
authored
Merge pull request #3603 from soyuka/merge-25
Merge 2.5
2 parents 9ccf578 + ff60de7 commit dabbcb6

40 files changed

+359
-98
lines changed

features/graphql/input_output.feature

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@ Feature: GraphQL DTO input and output
55

66
@createSchema
77
Scenario: Retrieve an Output with GraphQL
8+
Given there is a RelatedDummy with 0 friends
89
When I add "Content-Type" header equal to "application/ld+json"
910
And I send a "POST" request to "/dummy_dto_input_outputs" with body:
1011
"""
1112
{
1213
"foo": "test",
13-
"bar": 1
14+
"bar": 1,
15+
"relatedDummies": ["/related_dummies/1"]
1416
}
1517
"""
1618
Then the response status code should be 201
@@ -22,20 +24,51 @@ Feature: GraphQL DTO input and output
2224
"hydra": "http://www.w3.org/ns/hydra/core#",
2325
"id": "OutputDto/id",
2426
"baz": "OutputDto/baz",
25-
"bat": "OutputDto/bat"
27+
"bat": "OutputDto/bat",
28+
"relatedDummies": "OutputDto/relatedDummies"
2629
},
2730
"@type": "DummyDtoInputOutput",
2831
"@id": "/dummy_dto_input_outputs/1",
2932
"id": 1,
3033
"baz": 1,
31-
"bat": "test"
34+
"bat": "test",
35+
"relatedDummies": [
36+
{
37+
"@context": "/contexts/RelatedDummy",
38+
"@id": "/related_dummies/1",
39+
"@type": "https://schema.org/Product",
40+
"name": "RelatedDummy with friends",
41+
"dummyDate": null,
42+
"thirdLevel": null,
43+
"relatedToDummyFriend": [],
44+
"dummyBoolean": null,
45+
"embeddedDummy": {
46+
"dummyName": null,
47+
"dummyBoolean": null,
48+
"dummyDate": null,
49+
"dummyFloat": null,
50+
"dummyPrice": null,
51+
"symfony": null
52+
},
53+
"id": 1,
54+
"symfony": "symfony",
55+
"age": null
56+
}
57+
]
3258
}
3359
"""
3460
When I send the following GraphQL request:
3561
"""
3662
{
3763
dummyDtoInputOutput(id: "/dummy_dto_input_outputs/1") {
38-
_id, id, baz
64+
_id, id, baz,
65+
relatedDummies {
66+
edges {
67+
node {
68+
name
69+
}
70+
}
71+
}
3972
}
4073
}
4174
"""
@@ -49,7 +82,16 @@ Feature: GraphQL DTO input and output
4982
"dummyDtoInputOutput": {
5083
"_id": 1,
5184
"id": "/dummy_dto_input_outputs/1",
52-
"baz": 1
85+
"baz": 1,
86+
"relatedDummies": {
87+
"edges": [
88+
{
89+
"node": {
90+
"name": "RelatedDummy with friends"
91+
}
92+
}
93+
]
94+
}
5395
}
5496
}
5597
}

features/jsonld/input_output.feature

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -151,13 +151,15 @@ Feature: JSON-LD DTO input and output
151151
"hydra": "http://www.w3.org/ns/hydra/core#",
152152
"id": "OutputDto/id",
153153
"baz": "OutputDto/baz",
154-
"bat": "OutputDto/bat"
154+
"bat": "OutputDto/bat",
155+
"relatedDummies": "OutputDto/relatedDummies"
155156
},
156157
"@type": "DummyDtoInputOutput",
157158
"@id": "/dummy_dto_input_outputs/1",
158159
"id": 1,
159160
"baz": 1,
160-
"bat": "test"
161+
"bat": "test",
162+
"relatedDummies": []
161163
}
162164
"""
163165
When I add "Accept" header equal to "application/ld+json"
@@ -178,13 +180,15 @@ Feature: JSON-LD DTO input and output
178180
"hydra": "http://www.w3.org/ns/hydra/core#",
179181
"id": "OutputDto/id",
180182
"baz": "OutputDto/baz",
181-
"bat": "OutputDto/bat"
183+
"bat": "OutputDto/bat",
184+
"relatedDummies": "OutputDto/relatedDummies"
182185
},
183186
"@type": "DummyDtoInputOutput",
184187
"@id": "/dummy_dto_input_outputs/1",
185188
"id": 1,
186189
"baz": 2,
187-
"bat": "test"
190+
"bat": "test",
191+
"relatedDummies": []
188192
}
189193
"""
190194

@@ -237,13 +241,15 @@ Feature: JSON-LD DTO input and output
237241
"hydra": "http://www.w3.org/ns/hydra/core#",
238242
"id": "OutputDto/id",
239243
"baz": "OutputDto/baz",
240-
"bat": "OutputDto/bat"
244+
"bat": "OutputDto/bat",
245+
"relatedDummies": "OutputDto/relatedDummies"
241246
},
242247
"@type": "DummyDtoNoInput",
243248
"@id": "/dummy_dto_no_inputs/1",
244249
"id": 1,
245250
"baz": 1,
246-
"bat": "test"
251+
"bat": "test",
252+
"relatedDummies": []
247253
}
248254
"""
249255

@@ -260,13 +266,15 @@ Feature: JSON-LD DTO input and output
260266
"hydra": "http://www.w3.org/ns/hydra/core#",
261267
"id": "OutputDto/id",
262268
"baz": "OutputDto/baz",
263-
"bat": "OutputDto/bat"
269+
"bat": "OutputDto/bat",
270+
"relatedDummies": "OutputDto/relatedDummies"
264271
},
265272
"@type": "DummyDtoNoInput",
266273
"@id": "/dummy_dto_no_inputs/1",
267274
"id": 1,
268275
"baz": 1,
269-
"bat": "testtest"
276+
"bat": "testtest",
277+
"relatedDummies": []
270278
}
271279
"""
272280

phpstan.neon.dist

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ parameters:
88
symfony:
99
container_xml_path: tests/Fixtures/app/var/cache/test/appAppKernelTestDebugContainer.xml
1010
constant_hassers: false
11-
autoload_files:
11+
bootstrapFiles:
1212
- tests/Fixtures/app/AppKernel.php
1313
excludes_analyse:
1414
- tests/Fixtures/app/var/cache
@@ -132,3 +132,10 @@ parameters:
132132
-
133133
message: "#Call to function method_exists\\(\\) with ApiPlatform\\\\Core\\\\JsonApi\\\\Serializer\\\\ItemNormalizer and 'setCircularReferenc…' will always evaluate to false\\.#"
134134
path: tests/JsonApi/Serializer/ItemNormalizerTest.php
135+
136+
# Waiting to be fixed by https://github.com/Roave/BetterReflection/issues/663
137+
-
138+
message: '#Call to private method getNestedFieldPath\(\) of class ApiPlatform\\Core\\Bridge\\Elasticsearch\\DataProvider\\Filter\\AbstractFilter\.#'
139+
paths:
140+
- src/Bridge/Elasticsearch/DataProvider/Filter/OrderFilter.php
141+
- src/Bridge/Elasticsearch/DataProvider/Filter/AbstractSearchFilter.php

src/Bridge/Doctrine/Orm/Filter/ExistsFilter.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
use Doctrine\ORM\Query\Expr\Join;
2323
use Doctrine\ORM\QueryBuilder;
2424
use Psr\Log\LoggerInterface;
25+
use Symfony\Component\HttpFoundation\InputBag;
2526
use Symfony\Component\HttpFoundation\Request;
2627
use Symfony\Component\HttpFoundation\RequestStack;
2728
use Symfony\Component\Serializer\NameConverter\NameConverterInterface;
@@ -204,8 +205,13 @@ protected function extractProperties(Request $request/*, string $resourceClass*/
204205

205206
@trigger_error(sprintf('The use of "%s::extractProperties()" is deprecated since 2.2. Use the "filters" key of the context instead.', __CLASS__), E_USER_DEPRECATED);
206207

207-
$properties = $request->query->get($this->existsParameterName);
208+
// symfony > 5.1
209+
if (class_exists(InputBag::class)) {
210+
return $request->query->all($this->existsParameterName);
211+
}
208212

213+
$properties = $request->query->get($this->existsParameterName);
214+
/* @phpstan-ignore-next-line */
209215
return \is_array($properties) ? $properties : [];
210216
}
211217
}

src/Bridge/Doctrine/Orm/Filter/OrderFilter.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use Doctrine\ORM\Query\Expr\Join;
2121
use Doctrine\ORM\QueryBuilder;
2222
use Psr\Log\LoggerInterface;
23+
use Symfony\Component\HttpFoundation\InputBag;
2324
use Symfony\Component\HttpFoundation\Request;
2425
use Symfony\Component\HttpFoundation\RequestStack;
2526
use Symfony\Component\Serializer\NameConverter\NameConverterInterface;
@@ -120,8 +121,14 @@ protected function filterProperty(string $property, $direction, QueryBuilder $qu
120121
protected function extractProperties(Request $request/*, string $resourceClass*/): array
121122
{
122123
@trigger_error(sprintf('The use of "%s::extractProperties()" is deprecated since 2.2. Use the "filters" key of the context instead.', __CLASS__), E_USER_DEPRECATED);
123-
$properties = $request->query->get($this->orderParameterName);
124124

125+
// symfony > 5.1
126+
if (class_exists(InputBag::class)) {
127+
return $request->query->all($this->orderParameterName);
128+
}
129+
130+
$properties = $request->query->get($this->orderParameterName);
131+
/* @phpstan-ignore-next-line */
125132
return \is_array($properties) ? $properties : [];
126133
}
127134
}

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
use Symfony\Component\Config\Resource\DirectoryResource;
4444
use Symfony\Component\DependencyInjection\ChildDefinition;
4545
use Symfony\Component\DependencyInjection\ContainerBuilder;
46+
use Symfony\Component\DependencyInjection\Definition;
4647
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
4748
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
4849
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
@@ -147,6 +148,19 @@ private function registerCommonConfiguration(ContainerBuilder $container, array
147148
$loader->load('data_provider.xml');
148149
$loader->load('filter.xml');
149150

151+
$container->getDefinition('api_platform.operation_method_resolver')
152+
->setDeprecated(...$this->buildDeprecationArgs('2.5', 'The "%service_id%" service is deprecated since API Platform 2.5.'));
153+
$container->getDefinition('api_platform.formats_provider')
154+
->setDeprecated(...$this->buildDeprecationArgs('2.5', 'The "%service_id%" service is deprecated since API Platform 2.5.'));
155+
$container->getAlias('ApiPlatform\Core\Api\OperationAwareFormatsProviderInterface')
156+
->setDeprecated(...$this->buildDeprecationArgs('2.5', 'The "%alias_id%" alias is deprecated since API Platform 2.5.'));
157+
$container->getDefinition('api_platform.operation_path_resolver.underscore')
158+
->setDeprecated(...$this->buildDeprecationArgs('2.1', 'The "%service_id%" service is deprecated since API Platform 2.1 and will be removed in 3.0. Use "api_platform.path_segment_name_generator.underscore" instead.'));
159+
$container->getDefinition('api_platform.operation_path_resolver.dash')
160+
->setDeprecated(...$this->buildDeprecationArgs('2.1', 'The "%service_id%" service is deprecated since API Platform 2.1 and will be removed in 3.0. Use "api_platform.path_segment_name_generator.dash" instead.'));
161+
$container->getDefinition('api_platform.filters')
162+
->setDeprecated(...$this->buildDeprecationArgs('2.1', 'The "%service_id%" service is deprecated since 2.1 and will be removed in 3.0. Use the "api_platform.filter_locator" service instead.'));
163+
150164
if (class_exists(Uuid::class)) {
151165
$loader->load('ramsey_uuid.xml');
152166
}
@@ -460,6 +474,11 @@ private function registerLegacyBundlesConfiguration(ContainerBuilder $container,
460474

461475
if (isset($bundles['NelmioApiDocBundle']) && $config['enable_nelmio_api_doc']) {
462476
$loader->load('nelmio_api_doc.xml');
477+
478+
$container->getDefinition('api_platform.nelmio_api_doc.annotations_provider')
479+
->setDeprecated(...$this->buildDeprecationArgs('2.2', 'The "%service_id%" service is deprecated since API Platform 2.2 and will be removed in 3.0. NelmioApiDocBundle 3 has native support for API Platform.'));
480+
$container->getDefinition('api_platform.nelmio_api_doc.parser')
481+
->setDeprecated(...$this->buildDeprecationArgs('2.2', 'The "%service_id%" service is deprecated since API Platform 2.2 and will be removed in 3.0. NelmioApiDocBundle 3 has native support for API Platform.'));
463482
}
464483
}
465484

@@ -668,4 +687,11 @@ private function registerSecurityConfiguration(ContainerBuilder $container, XmlF
668687
$loader->load('security.xml');
669688
}
670689
}
690+
691+
private function buildDeprecationArgs(string $version, string $message): array
692+
{
693+
return method_exists(Definition::class, 'getDeprecation')
694+
? ['api-platform/core', $version, $message]
695+
: [true, $message];
696+
}
671697
}

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
use Symfony\Bundle\FullStack;
2828
use Symfony\Bundle\MercureBundle\MercureBundle;
2929
use Symfony\Bundle\TwigBundle\TwigBundle;
30+
use Symfony\Component\Config\Definition\BaseNode;
3031
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
3132
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
3233
use Symfony\Component\Config\Definition\ConfigurationInterface;
@@ -87,7 +88,7 @@ public function getConfigTreeBuilder()
8788
->booleanNode('show_webby')->defaultTrue()->info('If true, show Webby on the documentation page')->end()
8889
->scalarNode('default_operation_path_resolver')
8990
->defaultValue('api_platform.operation_path_resolver.underscore')
90-
->setDeprecated('The use of the `default_operation_path_resolver` has been deprecated in 2.1 and will be removed in 3.0. Use `path_segment_name_generator` instead.')
91+
->setDeprecated(...$this->buildDeprecationArgs('2.1', 'The use of the `default_operation_path_resolver` has been deprecated in 2.1 and will be removed in 3.0. Use `path_segment_name_generator` instead.'))
9192
->info('Specify the default operation path resolver to use for generating resources operations path.')
9293
->end()
9394
->scalarNode('name_converter')->defaultNull()->info('Specify a name converter to use.')->end()
@@ -111,7 +112,7 @@ public function getConfigTreeBuilder()
111112
->booleanNode('enable_fos_user')->defaultValue(class_exists(FOSUserBundle::class))->info('Enable the FOSUserBundle integration.')->end()
112113
->booleanNode('enable_nelmio_api_doc')
113114
->defaultFalse()
114-
->setDeprecated('Enabling the NelmioApiDocBundle integration has been deprecated in 2.2 and will be removed in 3.0. NelmioApiDocBundle 3 has native support for API Platform.')
115+
->setDeprecated(...$this->buildDeprecationArgs('2.2', 'Enabling the NelmioApiDocBundle integration has been deprecated in 2.2 and will be removed in 3.0. NelmioApiDocBundle 3 has native support for API Platform.'))
115116
->info('Enable the NelmioApiDocBundle integration.')
116117
->end()
117118
->booleanNode('enable_swagger')->defaultTrue()->info('Enable the Swagger documentation and export.')->end()
@@ -567,4 +568,11 @@ private function addDefaultsSection(ArrayNodeDefinition $rootNode): void
567568
$defaultsNode->children()->variableNode($snakeCased);
568569
}
569570
}
571+
572+
private function buildDeprecationArgs(string $version, string $message): array
573+
{
574+
return method_exists(BaseNode::class, 'getDeprecation')
575+
? ['api-platform/core', $version, $message]
576+
: [$message];
577+
}
570578
}

src/Bridge/Symfony/Bundle/Resources/config/api.xml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
<service id="api_platform.operation_method_resolver" class="ApiPlatform\Core\Bridge\Symfony\Routing\OperationMethodResolver" public="false">
1919
<argument type="service" id="api_platform.router" />
2020
<argument type="service" id="api_platform.metadata.resource.metadata_factory" />
21-
<deprecated>The "%service_id%" service is deprecated since API Platform 2.5.</deprecated>
2221
</service>
2322

2423
<service id="api_platform.route_name_resolver" class="ApiPlatform\Core\Bridge\Symfony\Routing\RouteNameResolver" public="false">
@@ -71,11 +70,9 @@
7170
<service id="api_platform.formats_provider" class="ApiPlatform\Core\Api\FormatsProvider">
7271
<argument type="service" id="api_platform.metadata.resource.metadata_factory" />
7372
<argument>%api_platform.formats%</argument>
74-
<deprecated>The "%service_id%" service is deprecated since API Platform 2.5.</deprecated>
7573
</service>
7674

7775
<service id="ApiPlatform\Core\Api\OperationAwareFormatsProviderInterface" alias="api_platform.formats_provider">
78-
<deprecated>The "%alias_id%" alias is deprecated since API Platform 2.5.</deprecated>
7976
</service>
8077

8178
<!-- Serializer -->
@@ -139,13 +136,9 @@
139136
<argument type="service" id="api_platform.path_segment_name_generator" />
140137
</service>
141138

142-
<service id="api_platform.operation_path_resolver.underscore" class="ApiPlatform\Core\PathResolver\UnderscoreOperationPathResolver" public="false">
143-
<deprecated>The "%service_id%" service is deprecated since API Platform 2.1 and will be removed in 3.0. Use "api_platform.path_segment_name_generator.underscore" instead.</deprecated>
144-
</service>
139+
<service id="api_platform.operation_path_resolver.underscore" class="ApiPlatform\Core\PathResolver\UnderscoreOperationPathResolver" public="false" />
145140

146-
<service id="api_platform.operation_path_resolver.dash" class="ApiPlatform\Core\PathResolver\DashOperationPathResolver" public="false">
147-
<deprecated>The "%service_id%" service is deprecated since API Platform 2.1 and will be removed in 3.0. Use "api_platform.path_segment_name_generator.dash" instead.</deprecated>
148-
</service>
141+
<service id="api_platform.operation_path_resolver.dash" class="ApiPlatform\Core\PathResolver\DashOperationPathResolver" public="false" />
149142

150143
<!-- Path name generator -->
151144

src/Bridge/Symfony/Bundle/Resources/config/filter.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
<service id="api_platform.filter_collection_factory" class="ApiPlatform\Core\Api\FilterCollectionFactory" />
1515

1616
<service id="api_platform.filters" class="ApiPlatform\Core\Api\FilterCollection">
17-
<deprecated>The "%service_id%" service is deprecated since 2.1 and will be removed in 3.0. Use the "api_platform.filter_locator" service instead.</deprecated>
1817
<factory service="api_platform.filter_collection_factory" method="createFilterCollectionFromLocator" />
1918
<argument type="service" id="api_platform.filter_locator" />
2019
</service>

src/Bridge/Symfony/Bundle/Resources/config/nelmio_api_doc.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66

77
<services>
88
<service id="api_platform.nelmio_api_doc.annotations_provider" class="ApiPlatform\Core\Bridge\NelmioApiDoc\Extractor\AnnotationsProvider\ApiPlatformProvider">
9-
<deprecated>The "%service_id%" service is deprecated since API Platform 2.2 and will be removed in 3.0. NelmioApiDocBundle 3 has native support for API Platform.</deprecated>
10-
119
<argument type="service" id="api_platform.metadata.resource.name_collection_factory" />
1210
<argument type="service" id="api_platform.hydra.normalizer.documentation" />
1311
<argument type="service" id="api_platform.metadata.resource.metadata_factory" />
@@ -18,8 +16,6 @@
1816
</service>
1917

2018
<service id="api_platform.nelmio_api_doc.parser" class="ApiPlatform\Core\Bridge\NelmioApiDoc\Parser\ApiPlatformParser">
21-
<deprecated>The "%service_id%" service is deprecated since API Platform 2.2 and will be removed in 3.0. NelmioApiDocBundle 3 has native support for API Platform.</deprecated>
22-
2319
<argument type="service" id="api_platform.metadata.resource.metadata_factory" />
2420
<argument type="service" id="api_platform.metadata.property.name_collection_factory" />
2521
<argument type="service" id="api_platform.metadata.property.metadata_factory" />

src/GraphQl/Action/EntrypointAction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ private function parseRequest(Request $request): array
9292
{
9393
$query = $request->query->get('query');
9494
$operationName = $request->query->get('operationName');
95-
if ($variables = $request->query->get('variables', [])) {
95+
if ($variables = $request->query->get('variables') ?: []) {
9696
$variables = $this->decodeVariables($variables);
9797
}
9898

0 commit comments

Comments
 (0)