Skip to content

Commit 2db20c6

Browse files
author
abluchet
committed
Add groups to subresource
1 parent d0dc684 commit 2db20c6

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/Bridge/Symfony/Routing/ApiLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ private function computeSubresourceOperations(RouteCollection $routeCollection,
173173
'_controller' => self::DEFAULT_ACTION_PATTERN.'get_subresource',
174174
'_format' => null,
175175
'_api_resource_class' => $subresource,
176-
'_api_subresource_operation_name' => 'get',
176+
'_api_subresource_operation_name' => 'get_subresource_'.$operation['property'],
177177
'_api_subresource_context' => [
178178
'property' => $operation['property'],
179179
'identifiers' => $operation['identifiers'],

tests/Fixtures/TestBundle/Entity/Answer.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,36 @@
1414

1515
use ApiPlatform\Core\Annotation\ApiResource;
1616
use Doctrine\ORM\Mapping as ORM;
17+
use Symfony\Component\Serializer\Annotation as Serializer;
1718

1819
/**
1920
* Answer.
2021
*
2122
* @ORM\Table(name="answer")
2223
* @ORM\Entity
23-
* @ApiResource
24+
* @ApiResource(collectionOperations={
25+
* "get_subresource_answer"={"method"="GET", "normalization_context"={"groups"={"foobar"}}}
26+
* })
2427
*/
2528
class Answer
2629
{
2730
/**
2831
* @ORM\Column(name="id", type="integer")
2932
* @ORM\Id
3033
* @ORM\GeneratedValue(strategy="AUTO")
34+
* @Serializer\Groups({"foobar"})
3135
*/
3236
private $id;
3337

3438
/**
3539
* @ORM\Column(name="content", type="string", nullable=false)
40+
* @Serializer\Groups({"foobar"})
3641
*/
3742
private $content;
3843

3944
/**
4045
* @ORM\OneToOne(targetEntity="Question", mappedBy="answer")
46+
* @Serializer\Groups({"foobar"})
4147
*/
4248
private $question;
4349

0 commit comments

Comments
 (0)