Subrecursos API Platform

De Wiki Proyectos Beta
Ir a la navegación Ir a la búsqueda

Descripción

Recursos

  • Documentación oficial: EN

Ejemplos API Platform 3

Ejemplo 1

#[ApiResource(
   uriTemplate: '/answers/{id}/related_questions.{_format}',
   uriVariables: [
       'id' => new Link(fromClass: Answer::class, fromProperty: 'relatedQuestions')
   ], 
   operations: [new GetCollection()]
)]

Ejemplo 2

#[ApiResource(
   uriTemplate: '/companies/{companyId}/employees/{id}',
   uriVariables: [
       'companyId' => new Link(fromClass: Company::class, toProperty: 'company'),
       'id' => new Link(fromClass: Employee::class),
   ],
   operations: [ new Get() ]
)]

Ejemplo 3

#[ApiResource(
   uriTemplate: '/companies/{companyId}/employees',
   uriVariables: [
       'companyId' => new Link(fromClass: Company::class, toProperty: 'company'),
   ],
   operations: [ new GetCollection() ]
)]