Custom controllers et paramètres différents de l'identifier
Publié le 26/04/2021 API Platform
Exemple :
<?php /** * @ApiResource( * attributes={"security"="is_granted('ROLE_USER')"}, * iri="http://schema.org/UserEntity", * collectionOperations={ * "userentitysite"={ * "method"="GET", * "path"="/userentities/entitysite/{identitysite}", * "pagination_enabled"=false, * "controller"=UserEntitysiteList::class, * "read"=false, * "openapi_context" = { * "summary" = "List attached to the requested entity/site pair", * "parameters" = { * { * "name"="identitysite", * "in" = "path", * "required" = true, * "type"="identity", * }, * }, * }, * }, * itemOperations={ * }, * formats={"jsonld", "json"}, * ) */ class UserEntity { // To force API Platform to not use identifier, you must put the new actions in // collectionOperations, even if there is some parameters ! In collections, // API Platform do not add the ID parameter ! }