php - Symfony - pass multiple params on Item operation
one text
I am using API Platform and don??�t think filters are used for item operations, but should I still be able to pass parameters to the endpoint and read them in the query handler?
I did not managed to find a way to read what is defined in Postman:
I defined the endpoint in the .xml
file:
<itemOperation name="share_as_guest">
<attribute name="path">/{id}/share-as-guest.{_format}</attribute>
<attribute name="method">GET</attribute>
<attribute name="output">App\ContentView</attribute>
</itemOperation>
Item Query Class:
class GetItemGuestQuery implements QueryInterface
{
private int $id;
public function __construct(int $id)
{
$this->id = $id;
}
public function id(): int
{
return $this->id;
}
}
Method in Data Provider:
public function getItem(string $resourceClass, $id, string $operationName = null, array $context = []): ?Content
{
return $this->queryBus->handle(
new GetItemGuestQuery(intval($id))
);
}
And method in Handler:
public function __invoke(GetItemGuestQuery $query)
{
return $this->port
->getGuest(
$query->id()
);
}
If filters are not applicable to Item operations, how should I pass parameters to the endpoint and read them in the query handler? I am struggling with finding the solution can someone please help?
Source