Enum.php 960 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\ApiResources\Enum;
  4. use ApiPlatform\Core\Annotation\ApiProperty;
  5. use ApiPlatform\Core\Annotation\ApiResource;
  6. /**
  7. * Classe resource qui contient les champs disponibles lors d'un appel à enum.
  8. */
  9. #[ApiResource(
  10. collectionOperations: [],
  11. itemOperations: [
  12. 'get' => [
  13. 'method' => 'GET',
  14. 'path' => '/enum/{name}'
  15. ]
  16. ]
  17. )]
  18. class Enum
  19. {
  20. #[ApiProperty(identifier: true)]
  21. private string $name;
  22. private array $items = [];
  23. public function __construct()
  24. {
  25. }
  26. public function getName(): string
  27. {
  28. return $this->name;
  29. }
  30. public function setName(string $name): self
  31. {
  32. $this->name = $name;
  33. return $this;
  34. }
  35. public function setItems(array $items): self
  36. {
  37. $this->items = $items;
  38. return $this;
  39. }
  40. public function getItems(): array
  41. {
  42. return $this->items;
  43. }
  44. }