AccessProfile.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\ApiResources\Profile;
  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 à my_profile.
  8. *
  9. * @ApiResource(
  10. * collectionOperations={},
  11. * itemOperations={
  12. * "get"={
  13. * "method"="GET",
  14. * "path"="/my_profile/{id}"
  15. * }
  16. * }
  17. * )
  18. */
  19. class AccessProfile
  20. {
  21. /**
  22. * @ApiProperty(identifier=true)
  23. */
  24. public $id;
  25. /**
  26. * @var string
  27. */
  28. private $name;
  29. /**
  30. * @var string
  31. */
  32. private $givenName;
  33. /**
  34. * @var array
  35. */
  36. private $roles = [];
  37. /**
  38. * @var OrganizationProfile
  39. */
  40. private $organization;
  41. public function __construct()
  42. {
  43. }
  44. public function getId(): ?int
  45. {
  46. return $this->id;
  47. }
  48. public function setId(?int $id): self
  49. {
  50. $this->id = $id;
  51. return $this;
  52. }
  53. public function getOrganization(): ?OrganizationProfile
  54. {
  55. return $this->organization;
  56. }
  57. public function setOrganization(?OrganizationProfile $organization): self
  58. {
  59. $this->organization = $organization;
  60. return $this;
  61. }
  62. public function getName(): ?string
  63. {
  64. return $this->name;
  65. }
  66. public function setName(?string $name): self
  67. {
  68. $this->name = $name;
  69. return $this;
  70. }
  71. public function getGivenName(): ?string
  72. {
  73. return $this->givenName;
  74. }
  75. public function setGivenName(?string $givenName): self
  76. {
  77. $this->givenName = $givenName;
  78. return $this;
  79. }
  80. /**
  81. * @inheritDoc
  82. */
  83. public function getRoles()
  84. {
  85. $roles = $this->roles;
  86. return array_unique($roles);
  87. }
  88. public function setRoles(array $roles): self
  89. {
  90. $this->roles = $roles;
  91. return $this;
  92. }
  93. }