Skip to content

Commit cbd025b

Browse files
committed
Merge 4.2
2 parents 63fba2a + c189691 commit cbd025b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+826
-283
lines changed

CHANGELOG.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,19 @@
77
* [21aa2572d](https://github.com/api-platform/core/commit/21aa2572d8fef2b3f05f7307c51348a6c9767e45) feat(elasticsearch): add SSL options for Elasticsearch configuration (#4059)
88
* [ba0c76c](https://github.com/api-platform/core/commit/ba0c76c6f5c8afa8622e87a155b8b99f453d6453) feat(doctrine): remove put & path for readonly entity (#7019)
99

10+
## v4.2.4
11+
12+
### Bug fixes
13+
14+
* [20f288959](https://github.com/api-platform/core/commit/20f288959a9d196dc64f859040306120b2496934) fix: multiple :property template operations on a single resource (#7461)
15+
* [44f227112](https://github.com/api-platform/core/commit/44f227112a2dd2380169643b70d783dbdd7e4936) fix(symfony): inject api-platform default configuration in the php resource metadata factory (#7525)
16+
* [921d7c8fe](https://github.com/api-platform/core/commit/921d7c8fe4fe61dbfcf3da8fbff7157b2866eb3e) fix(state): create PUT has relation with lazy mapper (#7521)
17+
* [951422e15](https://github.com/api-platform/core/commit/951422e15602ed2a4e0b66c7b8f8970cc0b3ac36) fix(openapi): maintain json schema for non-json operations (#7528)
18+
* [98fc35221](https://github.com/api-platform/core/commit/98fc352212e679d2753f94703989cb15b8f12891) fix(symfony): object mapper compatibility (#7531)
19+
* [a5c44624d](https://github.com/api-platform/core/commit/a5c44624d1a14488f1cb1a38033c8e44fe3111b4) fix(json-schema): pagination less schema with disabled pagination (#7506)
20+
* [da2324e82](https://github.com/api-platform/core/commit/da2324e82a53b03b1058606424c1175ab04373cd) fix(jsonschema): move jsonMergePatch postfix to DefinitionNameFactory (#7510)
21+
* [dc0df6110](https://github.com/api-platform/core/commit/dc0df6110366948869e20d94324380e12833a918) fix(iri): json streamer iri template does not need metadata (#7511)
22+
1023
## v4.2.3
1124

1225
* [9416083f7](https://github.com/api-platform/core/commit/9416083f7631b28093f3c79db995862338477137) fix(state): object mapper aware interface (#7486)
@@ -21,7 +34,6 @@
2134
* [fa6e206cc](https://github.com/api-platform/core/commit/fa6e206cc3cf20aa4535ad2fd83d9e53f56e713c) fix(state): detect mapping on source (#7475)
2235
* [fafbe5c7b](https://github.com/api-platform/core/commit/fafbe5c7b1418c33baea2506458449562001d2fa) fix(validator): custom message was not translated (#7424)
2336

24-
2537
### Features
2638

2739
* [f5c257dab](https://github.com/api-platform/core/commit/f5c257dab98624e99e57603692a73b6b3ae5c7f0) feat(symfony): convert routing files to php-dsl (#7463)
@@ -337,6 +349,13 @@ TypeInfo:
337349
* [cff61eab8](https://github.com/api-platform/core/commit/cff61eab8643f8ed08d59c0684e77740d0d81b04) fix(metadata): append php file resource extractor (#7193)
338350
* [f3d4afe03](https://github.com/api-platform/core/commit/f3d4afe032385f3b665131a365e42706930f0730) fix(symfony): validator type-info
339351

352+
## v4.1.27
353+
354+
### Bug fixes
355+
356+
* [3df65aa86](https://github.com/api-platform/core/commit/3df65aa86e9e4ececd5e64104b8815b3f8320d8e) fix(symfony): allow disabling PHPStan PhpDocParser (#7507)
357+
* [7c76fb8ea](https://github.com/api-platform/core/commit/7c76fb8ea0dac24ec3f8a1495a9416facdad23f1) fix(jsonld): read identifier with itemUriTemplate (#7517)
358+
340359
## v4.1.26
341360

342361
### Bug fixes

composer.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"doctrine/mongodb-odm": "<2.4",
4040
"doctrine/persistence": "<1.3",
4141
"symfony/framework-bundle": "6.4.6 || 7.0.6",
42+
"symfony/object-mapper": "<7.3.4",
4243
"symfony/var-exporter": "<6.1.1",
4344
"phpunit/phpunit": "<9.5",
4445
"phpspec/prophecy": "<1.15"
@@ -110,14 +111,14 @@
110111
"psr/cache": "^1.0 || ^2.0 || ^3.0",
111112
"psr/container": "^1.0 || ^2.0",
112113
"symfony/deprecation-contracts": "^3.1",
113-
"symfony/http-foundation": "^6.4 || ^7.0",
114+
"symfony/http-foundation": "^6.4.14 || ^7.0",
114115
"symfony/http-kernel": "^6.4 || ^7.0",
115116
"symfony/property-access": "^6.4 || ^7.0",
116117
"symfony/property-info": "^6.4 || ^7.1",
117118
"symfony/serializer": "^6.4 || ^7.0",
118119
"symfony/translation-contracts": "^3.3",
119120
"symfony/type-info": "^7.3 || 7.4.x-dev",
120-
"symfony/validator": "^6.4 || ^7.1",
121+
"symfony/validator": "^6.4.11 || ^7.1",
121122
"symfony/web-link": "^6.4 || ^7.1",
122123
"willdurand/negotiation": "^3.1"
123124
},
@@ -183,15 +184,15 @@
183184
"symfony/maker-bundle": "^1.24",
184185
"symfony/mercure-bundle": "*",
185186
"symfony/messenger": "^6.4 || ^7.0",
186-
"symfony/object-mapper": "7.4.x-dev",
187+
"symfony/object-mapper": "^7.3 || 7.4.x-dev",
187188
"symfony/routing": "^6.4 || ^7.0",
188189
"symfony/security-bundle": "^6.4 || ^7.0",
189190
"symfony/security-core": "^6.4 || ^7.0",
190191
"symfony/stopwatch": "^6.4 || ^7.0",
191192
"symfony/string": "^6.4 || ^7.0",
192193
"symfony/twig-bundle": "^6.4 || ^7.0",
193194
"symfony/uid": "^6.4 || ^7.0",
194-
"symfony/validator": "^6.4 || ^7.0",
195+
"symfony/var-exporter": "^7.3 || ^7.4.x-dev",
195196
"symfony/web-profiler-bundle": "^6.4 || ^7.0",
196197
"symfony/yaml": "^6.4 || ^7.0",
197198
"twig/twig": "^1.42.3 || ^2.12 || ^3.0",

src/Doctrine/Common/State/PersistProcessor.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ public function process(mixed $data, Operation $operation, array $uriVariables =
7878
$reflectionProperty->setValue($newData, $newValue);
7979
}
8080
}
81+
// We create a new entity through PUT
8182
} else {
8283
foreach (array_reverse($links) as $link) {
8384
if ($link->getExpandedValue() || !$link->getFromClass()) {
@@ -92,6 +93,45 @@ public function process(mixed $data, Operation $operation, array $uriVariables =
9293
$reflectionProperty->setValue($newData, $this->getIdentifierValue($identifiers, $hasCompositeIdentifiers ? $identifierProperty : null));
9394
}
9495
}
96+
97+
$classMetadata = $manager->getClassMetadata($class);
98+
foreach ($reflectionProperties as $propertyName => $reflectionProperty) {
99+
if ($classMetadata->isIdentifier($propertyName)) {
100+
continue;
101+
}
102+
103+
$value = $reflectionProperty->getValue($newData);
104+
105+
if (!\is_object($value)) {
106+
continue;
107+
}
108+
109+
if (
110+
!($relManager = $this->managerRegistry->getManagerForClass($class = $this->getObjectClass($value)))
111+
|| $relManager->contains($value)
112+
) {
113+
continue;
114+
}
115+
116+
if (\PHP_VERSION_ID > 80400) {
117+
$r = new \ReflectionClass($value);
118+
if ($r->isUninitializedLazyObject($value)) {
119+
$r->initializeLazyObject($value);
120+
}
121+
}
122+
123+
$metadata = $manager->getClassMetadata($class);
124+
$identifiers = $metadata->getIdentifierValues($value);
125+
126+
// Do not get reference for partial objects or objects with null identifiers
127+
if (!$identifiers || \count($identifiers) !== \count(array_filter($identifiers, static fn ($v) => null !== $v))) {
128+
continue;
129+
}
130+
131+
\assert(method_exists($relManager, 'getReference'));
132+
133+
$reflectionProperty->setValue($newData, $relManager->getReference($class, $identifiers));
134+
}
95135
}
96136

97137
$data = $newData;

src/Doctrine/Common/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"require": {
2626
"php": ">=8.2",
2727
"api-platform/metadata": "^4.2",
28-
"api-platform/state": "^4.2",
28+
"api-platform/state": "^4.2.4",
2929
"doctrine/collections": "^2.1",
3030
"doctrine/common": "^3.2.2",
3131
"doctrine/persistence": "^3.2 || ^4.0"

src/Doctrine/Odm/composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"php": ">=8.2",
2828
"api-platform/doctrine-common": "^4.2",
2929
"api-platform/metadata": "^4.2",
30-
"api-platform/state": "^4.2",
30+
"api-platform/state": "^4.2.4",
3131
"doctrine/mongodb-odm": "^2.10",
3232
"symfony/property-info": "^6.4 || ^7.1",
3333
"symfony/type-info": "^7.3"
@@ -42,7 +42,7 @@
4242
"symfony/property-access": "^6.4 || ^7.0",
4343
"symfony/serializer": "^6.4 || ^7.0",
4444
"symfony/uid": "^6.4 || ^7.0",
45-
"symfony/validator": "^6.4 || ^7.0",
45+
"symfony/validator": "^6.4.11 || ^7.0",
4646
"symfony/yaml": "^6.4 || ^7.0"
4747
},
4848
"autoload": {

src/Doctrine/Orm/composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"php": ">=8.2",
2727
"api-platform/doctrine-common": "^4.2.0-alpha.3@alpha",
2828
"api-platform/metadata": "^4.2",
29-
"api-platform/state": "^4.2",
29+
"api-platform/state": "^4.2.4",
3030
"doctrine/orm": "^2.17 || ^3.0",
3131
"symfony/type-info": "^7.3"
3232
},
@@ -42,7 +42,7 @@
4242
"symfony/serializer": "^6.4 || ^7.0",
4343
"symfony/property-info": "^6.4 || ^7.1",
4444
"symfony/uid": "^6.4 || ^7.0",
45-
"symfony/validator": "^6.4 || ^7.0",
45+
"symfony/validator": "^6.4.11 || ^7.0",
4646
"symfony/yaml": "^6.4 || ^7.0"
4747
},
4848
"autoload": {

src/Elasticsearch/composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
"require": {
2626
"php": ">=8.2",
2727
"api-platform/metadata": "^4.2",
28-
"api-platform/serializer": "^4.2",
29-
"api-platform/state": "^4.2",
28+
"api-platform/serializer": "^4.2.4",
29+
"api-platform/state": "^4.2.4",
3030
"elasticsearch/elasticsearch": "^7.17 || ^8.4",
3131
"symfony/cache": "^6.4 || ^7.0",
3232
"symfony/console": "^6.4 || ^7.0",

src/GraphQl/composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
"require": {
2323
"php": ">=8.2",
2424
"api-platform/metadata": "^4.2",
25-
"api-platform/state": "^4.2",
26-
"api-platform/serializer": "^4.2",
25+
"api-platform/state": "^4.2.4",
26+
"api-platform/serializer": "^4.2.4",
2727
"symfony/property-info": "^7.1",
2828
"symfony/serializer": "^6.4 || ^7.1",
2929
"symfony/type-info": "^7.3",
@@ -32,7 +32,7 @@
3232
},
3333
"require-dev": {
3434
"phpspec/prophecy-phpunit": "^2.2",
35-
"api-platform/validator": "^4.2",
35+
"api-platform/validator": "^4.2.4",
3636
"twig/twig": "^1.42.3 || ^2.12 || ^3.0",
3737
"symfony/mercure-bundle": "*",
3838
"symfony/routing": "^6.4 || ^7.0",

src/Hal/JsonSchema/SchemaFactory.php

Lines changed: 42 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ final class SchemaFactory implements SchemaFactoryInterface, SchemaFactoryAwareI
3535
use SchemaUriPrefixTrait;
3636

3737
private const COLLECTION_BASE_SCHEMA_NAME = 'HalCollectionBaseSchema';
38+
private const COLLECTION_BASE_SCHEMA_NAME_NO_PAGINATION = 'HalCollectionBaseSchemaNoPagination';
3839

3940
private const HREF_PROP = [
4041
'href' => [
@@ -122,10 +123,14 @@ public function buildSchema(string $className, string $format = 'jsonhal', strin
122123
}
123124

124125
if (($schema['type'] ?? '') === 'array') {
125-
if (!isset($definitions[self::COLLECTION_BASE_SCHEMA_NAME])) {
126-
$definitions[self::COLLECTION_BASE_SCHEMA_NAME] = [
126+
if (!isset($definitions[self::COLLECTION_BASE_SCHEMA_NAME_NO_PAGINATION])) {
127+
$definitions[self::COLLECTION_BASE_SCHEMA_NAME_NO_PAGINATION] = [
127128
'type' => 'object',
128129
'properties' => [
130+
'totalItems' => [
131+
'type' => 'integer',
132+
'minimum' => 0,
133+
],
129134
'_embedded' => [
130135
'anyOf' => [
131136
[
@@ -139,41 +144,52 @@ public function buildSchema(string $className, string $format = 'jsonhal', strin
139144
['type' => 'object'],
140145
],
141146
],
142-
'totalItems' => [
143-
'type' => 'integer',
144-
'minimum' => 0,
145-
],
146-
'itemsPerPage' => [
147-
'type' => 'integer',
148-
'minimum' => 0,
149-
],
150147
'_links' => [
151148
'type' => 'object',
152149
'properties' => [
153150
'self' => [
154151
'type' => 'object',
155152
'properties' => self::HREF_PROP,
156153
],
157-
'first' => [
158-
'type' => 'object',
159-
'properties' => self::HREF_PROP,
160-
],
161-
'last' => [
162-
'type' => 'object',
163-
'properties' => self::HREF_PROP,
164-
],
165-
'next' => [
166-
'type' => 'object',
167-
'properties' => self::HREF_PROP,
154+
],
155+
],
156+
],
157+
'required' => ['_links', '_embedded'],
158+
];
159+
160+
$definitions[self::COLLECTION_BASE_SCHEMA_NAME] = [
161+
'allOf' => [
162+
['$ref' => $prefix.self::COLLECTION_BASE_SCHEMA_NAME_NO_PAGINATION],
163+
[
164+
'type' => 'object',
165+
'properties' => [
166+
'itemsPerPage' => [
167+
'type' => 'integer',
168+
'minimum' => 0,
168169
],
169-
'previous' => [
170-
'type' => 'object',
171-
'properties' => self::HREF_PROP,
170+
'_links' => [
171+
'properties' => [
172+
'first' => [
173+
'type' => 'object',
174+
'properties' => self::HREF_PROP,
175+
],
176+
'last' => [
177+
'type' => 'object',
178+
'properties' => self::HREF_PROP,
179+
],
180+
'next' => [
181+
'type' => 'object',
182+
'properties' => self::HREF_PROP,
183+
],
184+
'previous' => [
185+
'type' => 'object',
186+
'properties' => self::HREF_PROP,
187+
],
188+
],
172189
],
173190
],
174191
],
175192
],
176-
'required' => ['_links', '_embedded'],
177193
];
178194
}
179195

@@ -182,7 +198,7 @@ public function buildSchema(string $className, string $format = 'jsonhal', strin
182198

183199
$schema['description'] = "$definitionName collection.";
184200
$schema['allOf'] = [
185-
['$ref' => $prefix.self::COLLECTION_BASE_SCHEMA_NAME],
201+
['$ref' => $prefix.(false === $operation->getPaginationEnabled() ? self::COLLECTION_BASE_SCHEMA_NAME_NO_PAGINATION : self::COLLECTION_BASE_SCHEMA_NAME)],
186202
[
187203
'type' => 'object',
188204
'properties' => [

src/Hal/composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222
],
2323
"require": {
2424
"php": ">=8.2",
25-
"api-platform/state": "^4.2",
25+
"api-platform/state": "^4.2.4",
2626
"api-platform/metadata": "^4.2",
2727
"api-platform/documentation": "^4.2",
28-
"api-platform/serializer": "^4.2",
28+
"api-platform/serializer": "^4.2.4",
2929
"symfony/type-info": "^7.3"
3030
},
3131
"autoload": {

0 commit comments

Comments
 (0)