Skip to content

Commit c08697c

Browse files
committed
Merge 2.7 into 3.0
2 parents 177cc3c + 79f5486 commit c08697c

File tree

6 files changed

+128
-0
lines changed

6 files changed

+128
-0
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,12 @@ Breaking changes:
163163
* Metadata: `Patch` is added to the automatic CRUD
164164
* Symfony: generated route names and operation names changed, route naming can be changed directly within metadata
165165

166+
## v2.7.11
167+
168+
### Bug fixes
169+
170+
* [01ce3f811](https://github.com/api-platform/core/commit/01ce3f8110b2e3fe13077bec3fadaff653e4a512) fix(serializer): find parent class operation (#5449)
171+
166172
## v2.7.10
167173

168174
### Bug fixes
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Feature: Inheritance with correct IRIs
2+
In order to fix (https://github.com/api-platform/core/issues/5438)
3+
4+
Scenario: Get the collection of people with its employees
5+
When I add "Accept" header equal to "application/json"
6+
And I send a "GET" request to "/people_5438"
7+
Then print last JSON response
8+
9+
Scenario: Get the collection of people with its employees
10+
When I add "Accept" header equal to "application/ld+json"
11+
And I send a "GET" request to "/people_5438"
12+
Then print last JSON response

src/Serializer/AbstractItemNormalizer.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ public function normalize(mixed $object, string $format = null, array $context =
116116
}
117117

118118
if (isset($context['operation']) && $context['operation'] instanceof CollectionOperationInterface) {
119+
unset($context['operation_name']);
119120
unset($context['operation']);
120121
unset($context['iri']);
121122
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the API Platform project.
5+
*
6+
* (c) Kévin Dunglas <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
declare(strict_types=1);
13+
14+
namespace ApiPlatform\Tests\Fixtures\TestBundle\ApiResource\Issue5438;
15+
16+
use ApiPlatform\Metadata\Get;
17+
use ApiPlatform\Metadata\Operation;
18+
19+
#[Get(
20+
shortName: 'Contractor5438',
21+
uriTemplate: 'contractor_5438/{id}',
22+
provider: [Contractor::class, 'getContractor'],
23+
)]
24+
class Contractor extends Person
25+
{
26+
public static function getContractor(Operation $operation, array $uriVariables = []): self
27+
{
28+
return new self(
29+
$uriVariables['id'],
30+
'a'
31+
);
32+
}
33+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the API Platform project.
5+
*
6+
* (c) Kévin Dunglas <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
declare(strict_types=1);
13+
14+
namespace ApiPlatform\Tests\Fixtures\TestBundle\ApiResource\Issue5438;
15+
16+
use ApiPlatform\Metadata\Get;
17+
use ApiPlatform\Metadata\Operation;
18+
19+
#[Get(
20+
shortName: 'Employee5438',
21+
uriTemplate: 'employee_5438/{id}',
22+
provider: [Employee::class, 'getEmployee']
23+
)]
24+
class Employee extends Person
25+
{
26+
public static function getEmployee(Operation $operation, array $uriVariables = []): self
27+
{
28+
return new self(
29+
$uriVariables['id'],
30+
'a'
31+
);
32+
}
33+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the API Platform project.
5+
*
6+
* (c) Kévin Dunglas <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
declare(strict_types=1);
13+
14+
namespace ApiPlatform\Tests\Fixtures\TestBundle\ApiResource\Issue5438;
15+
16+
use ApiPlatform\Metadata\GetCollection;
17+
use ApiPlatform\Metadata\Operation;
18+
19+
#[GetCollection(
20+
shortName: 'People5438',
21+
uriTemplate: 'people_5438',
22+
provider: [Person::class, 'getData']
23+
)]
24+
abstract class Person
25+
{
26+
public function __construct(public readonly ?int $id = null, public readonly ?string $name = null)
27+
{
28+
}
29+
30+
public static function getData(Operation $operation, array $uriVariables = []): iterable
31+
{
32+
return [
33+
new Contractor(
34+
1,
35+
'a'
36+
),
37+
new Employee(
38+
2,
39+
'b'
40+
),
41+
];
42+
}
43+
}

0 commit comments

Comments
 (0)