UserSearchItem.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity\Custom\Search;
  4. use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
  5. use ApiPlatform\Metadata\ApiFilter;
  6. use ApiPlatform\Metadata\ApiResource;
  7. use ApiPlatform\Metadata\Get;
  8. use ApiPlatform\Metadata\GetCollection;
  9. use App\Filter\ApiPlatform\Utils\InFilter;
  10. use App\Repository\Custom\Search\UserSearchItemRepository;
  11. use Doctrine\ORM\Mapping as ORM;
  12. /**
  13. * Données réduites d'identification d'un utilisateur (ids, noms)
  14. * Utilisées entre autres pour les listes déroulantes de recherche.
  15. * TODO: revoir sécurité
  16. *
  17. * Fichier source de la view : ./sql/schema-extensions/003-view_search_user.sql
  18. */
  19. #[ApiResource(
  20. operations: [
  21. new Get(
  22. uriTemplate: '/search/users/{id}'
  23. ),
  24. new GetCollection(
  25. uriTemplate: '/search/users',
  26. ),
  27. ]
  28. )]
  29. #[ORM\Table(name: 'view_search_user')]
  30. #[ORM\Entity(repositoryClass: UserSearchItemRepository::class, readOnly: true)]
  31. #[ApiFilter(filterClass: InFilter::class, properties: ['id'])]
  32. #[ApiFilter(filterClass: SearchFilter::class, properties: ['fullname' => 'ipartial'])]
  33. class UserSearchItem
  34. {
  35. #[ORM\Id]
  36. #[ORM\Column]
  37. private int $id;
  38. #[ORM\Column(type: 'integer')]
  39. private ?int $organizationId = null;
  40. #[ORM\Column(type: 'integer')]
  41. private ?int $personId = null;
  42. #[ORM\Column(type: 'string')]
  43. private ?string $username = null;
  44. #[ORM\Column(type: 'string')]
  45. private ?string $name = null;
  46. #[ORM\Column(type: 'string')]
  47. private ?string $givenName = null;
  48. #[ORM\Column(type: 'string')]
  49. private ?string $fullName = null;
  50. public function getId(): int
  51. {
  52. return $this->id;
  53. }
  54. public function setId(int $id): self
  55. {
  56. $this->id = $id;
  57. return $this;
  58. }
  59. public function getOrganizationId(): ?int
  60. {
  61. return $this->organizationId;
  62. }
  63. public function setOrganizationId(?int $organizationId): self
  64. {
  65. $this->organizationId = $organizationId;
  66. return $this;
  67. }
  68. public function getPersonId(): ?int
  69. {
  70. return $this->personId;
  71. }
  72. public function setPersonId(?int $personId): self
  73. {
  74. $this->personId = $personId;
  75. return $this;
  76. }
  77. public function getUsername(): ?string
  78. {
  79. return $this->username;
  80. }
  81. public function setUsername(?string $username): self
  82. {
  83. $this->username = $username;
  84. return $this;
  85. }
  86. public function getName(): ?string
  87. {
  88. return $this->name;
  89. }
  90. public function setName(?string $name): self
  91. {
  92. $this->name = $name;
  93. return $this;
  94. }
  95. public function getGivenName(): ?string
  96. {
  97. return $this->givenName;
  98. }
  99. public function setGivenName(?string $givenName): self
  100. {
  101. $this->givenName = $givenName;
  102. return $this;
  103. }
  104. public function getFullName(): ?string
  105. {
  106. return $this->fullName;
  107. }
  108. public function setFullName(?string $fullName): self
  109. {
  110. $this->fullName = $fullName;
  111. return $this;
  112. }
  113. }