Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(serializer): uriTemplate wrong cache usage in hal format (#6313)
* add failing test * prevent components caching between different subresources * fix tests for MongoDB
- Loading branch information
Showing
8 changed files
with
232 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
tests/Fixtures/TestBundle/Document/PropertyCollectionIriOnlyRelationSecondLevel.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the API Platform project. | ||
* | ||
* (c) Kévin Dunglas <dunglas@gmail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ApiPlatform\Tests\Fixtures\TestBundle\Document; | ||
|
||
use ApiPlatform\Metadata\GetCollection; | ||
use ApiPlatform\Metadata\Link; | ||
use ApiPlatform\Metadata\Post; | ||
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM; | ||
|
||
#[ | ||
Post, | ||
GetCollection(uriTemplate: '/property-collection-relation-second-levels'), | ||
GetCollection( | ||
uriTemplate: '/property_collection_iri_only_relations/{parentId}/children', | ||
uriVariables: [ | ||
'parentId' => new Link(toProperty: 'parent', fromClass: PropertyCollectionIriOnlyRelation::class), | ||
] | ||
) | ||
] | ||
#[ODM\Document] | ||
class PropertyCollectionIriOnlyRelationSecondLevel | ||
{ | ||
#[ODM\Id(strategy: 'INCREMENT', type: 'int')] | ||
private ?int $id = null; | ||
|
||
#[ODM\ReferenceOne(targetDocument: PropertyCollectionIriOnlyRelation::class)] | ||
private ?PropertyCollectionIriOnlyRelation $parent = null; | ||
|
||
public function getId(): ?int | ||
{ | ||
return $this->id ?? 9999; | ||
} | ||
|
||
public function getParent(): ?PropertyCollectionIriOnlyRelation | ||
{ | ||
return $this->parent; | ||
} | ||
|
||
public function setParent(?PropertyCollectionIriOnlyRelation $parent): void | ||
{ | ||
$this->parent = $parent; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
tests/Fixtures/TestBundle/Entity/PropertyCollectionIriOnlyRelationSecondLevel.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the API Platform project. | ||
* | ||
* (c) Kévin Dunglas <dunglas@gmail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ApiPlatform\Tests\Fixtures\TestBundle\Entity; | ||
|
||
use ApiPlatform\Metadata\GetCollection; | ||
use ApiPlatform\Metadata\Link; | ||
use ApiPlatform\Metadata\Post; | ||
use Doctrine\ORM\Mapping as ORM; | ||
|
||
#[ | ||
Post, | ||
GetCollection(uriTemplate: '/property-collection-relation-second-levels'), | ||
GetCollection( | ||
uriTemplate: '/property_collection_iri_only_relations/{parentId}/children', | ||
uriVariables: [ | ||
'parentId' => new Link(toProperty: 'parent', fromClass: PropertyCollectionIriOnlyRelation::class), | ||
] | ||
) | ||
] | ||
#[ORM\Entity] | ||
class PropertyCollectionIriOnlyRelationSecondLevel | ||
{ | ||
/** | ||
* The entity ID. | ||
*/ | ||
#[ORM\Id] | ||
#[ORM\Column(type: 'integer')] | ||
#[ORM\GeneratedValue] | ||
private ?int $id = null; | ||
|
||
#[ORM\ManyToOne(inversedBy: 'children')] | ||
private ?PropertyCollectionIriOnlyRelation $parent = null; | ||
|
||
public function getId(): ?int | ||
{ | ||
return $this->id ?? 9999; | ||
} | ||
|
||
public function getParent(): ?PropertyCollectionIriOnlyRelation | ||
{ | ||
return $this->parent; | ||
} | ||
|
||
public function setParent(?PropertyCollectionIriOnlyRelation $parent): void | ||
{ | ||
$this->parent = $parent; | ||
} | ||
} |