-
-
Notifications
You must be signed in to change notification settings - Fork 848
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(metadata): notexposed no urivariables inheritance (#5765)
* fix(metadata): notexposed no urivariables inheritance * use named arguments Co-authored-by: Vincent <407859+vincentchalamon@users.noreply.github.com> * fix tests --------- Co-authored-by: Vincent <407859+vincentchalamon@users.noreply.github.com>
- Loading branch information
1 parent
e2e59b0
commit 07c9989
Showing
7 changed files
with
158 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Feature: Get a subresource from inverse side that has no item operation | ||
|
||
@!mongodb | ||
@createSchema | ||
Scenario: Get a subresource from inverse side that has no item operation | ||
Given there are logs on an event | ||
When I send a "GET" request to "/events/03af3507-271e-4cca-8eee-6244fb06e95b/logs" | ||
Then the response status code should be 200 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?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\Issue5722; | ||
|
||
use ApiPlatform\Metadata\ApiProperty; | ||
use ApiPlatform\Metadata\ApiResource; | ||
use ApiPlatform\Metadata\Get; | ||
use ApiPlatform\Metadata\GetCollection; | ||
use Doctrine\Common\Collections\ArrayCollection; | ||
use Doctrine\Common\Collections\Collection; | ||
use Doctrine\ORM\Mapping as ORM; | ||
use Ramsey\Uuid\Uuid; | ||
|
||
#[ApiResource( | ||
shortName: 'EventIssue5722', | ||
operations: [ | ||
new GetCollection(), | ||
new Get(), | ||
], | ||
)] | ||
#[ORM\Entity] | ||
class Event | ||
{ | ||
#[ORM\Id] | ||
#[ORM\Column(type: 'integer')] | ||
#[ORM\GeneratedValue(strategy: 'AUTO')] | ||
#[ApiProperty(readable: false, writable: false, identifier: false)] | ||
public $id; | ||
|
||
#[ApiProperty(writable: false, identifier: true)] | ||
#[ORM\Column(type: 'uuid', unique: true)] | ||
public $uuid; | ||
|
||
#[ORM\OneToMany(targetEntity: ItemLog::class, cascade: ['persist'], orphanRemoval: false, mappedBy: 'item')] | ||
public Collection $logs; | ||
|
||
public function __construct() | ||
{ | ||
$this->logs = new ArrayCollection(); | ||
$this->uuid = Uuid::uuid4(); | ||
} | ||
} |
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,70 @@ | ||
<?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\Issue5722; | ||
|
||
use ApiPlatform\Metadata\ApiProperty; | ||
use ApiPlatform\Metadata\ApiResource; | ||
use ApiPlatform\Metadata\GetCollection; | ||
use ApiPlatform\Metadata\Link; | ||
use Doctrine\ORM\Mapping as ORM; | ||
use Ramsey\Uuid\Uuid; | ||
|
||
#[ApiResource( | ||
shortName: 'ItemLogIssue5722', | ||
operations: [ | ||
new GetCollection(), | ||
], | ||
)] | ||
#[ApiResource( | ||
uriTemplate: '/events/{uuid}/logs{._format}', | ||
operations: [ | ||
new GetCollection(), | ||
], | ||
uriVariables: [ | ||
'uuid' => new Link(fromProperty: 'logs', fromClass: Event::class), | ||
], | ||
)] | ||
#[ORM\Entity] | ||
class ItemLog | ||
{ | ||
#[ORM\Id] | ||
#[ORM\Column(type: 'integer')] | ||
#[ORM\GeneratedValue(strategy: 'AUTO')] | ||
#[ApiProperty(readable: false, writable: false, identifier: false)] // identifier was false before 3.1.14, changing this to true fixed some errors | ||
private ?int $id = null; | ||
|
||
#[ApiProperty(writable: false, identifier: true)] | ||
#[ORM\Column(type: 'uuid', unique: true)] | ||
public $uuid; | ||
|
||
#[ORM\ManyToOne(targetEntity: Event::class, inversedBy: 'logs')] | ||
public ?Event $item = null; | ||
|
||
#[ApiProperty(required: true)] | ||
#[ORM\Column] | ||
public string $action = 'insert'; | ||
|
||
private \DateTimeInterface $createdAt; | ||
|
||
public function __construct() | ||
{ | ||
$this->createdAt = new \DateTime(); | ||
$this->uuid = Uuid::uuid4(); | ||
} | ||
|
||
public function getId(): ?int | ||
{ | ||
return $this->id; | ||
} | ||
} |