| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- <?php
- declare(strict_types=1);
- namespace App\Entity\Custom\Search;
- use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
- use ApiPlatform\Metadata\ApiFilter;
- use ApiPlatform\Metadata\ApiResource;
- use ApiPlatform\Metadata\Get;
- use ApiPlatform\Metadata\GetCollection;
- use App\Filter\ApiPlatform\Utils\InFilter;
- use App\Repository\Custom\Search\UserSearchItemRepository;
- use Doctrine\ORM\Mapping as ORM;
- /**
- * Données réduites d'identification d'un utilisateur (ids, noms)
- * Utilisées entre autres pour les listes déroulantes de recherche.
- * TODO: revoir sécurité
- *
- * Fichier source de la view : ./sql/schema-extensions/003-view_search_user.sql
- */
- #[ApiResource(
- operations: [
- new Get(
- uriTemplate: '/search/users/{id}'
- ),
- new GetCollection(
- uriTemplate: '/search/users',
- paginationMaximumItemsPerPage: 10,
- paginationClientItemsPerPage: true,
- order: ['name' => 'ASC']
- ),
- ]
- )]
- #[ORM\Table(name: 'view_search_user')]
- #[ORM\Entity(repositoryClass: UserSearchItemRepository::class, readOnly: true)]
- #[ApiFilter(filterClass: InFilter::class, properties: ['id'])]
- #[ApiFilter(filterClass: SearchFilter::class, properties: ['fullname' => 'ipartial'])]
- class UserSearchItem
- {
- #[ORM\Id]
- #[ORM\Column]
- private int $id;
- #[ORM\Column(type: 'integer')]
- private ?int $organizationId = null;
- #[ORM\Column(type: 'integer')]
- private ?int $personId = null;
- #[ORM\Column(type: 'string')]
- private ?string $username = null;
- #[ORM\Column(type: 'string')]
- private ?string $name = null;
- #[ORM\Column(type: 'string')]
- private ?string $givenName = null;
- #[ORM\Column(type: 'string')]
- private ?string $fullName = null;
- public function getId(): int
- {
- return $this->id;
- }
- public function setId(int $id): self
- {
- $this->id = $id;
- return $this;
- }
- public function getOrganizationId(): ?int
- {
- return $this->organizationId;
- }
- public function setOrganizationId(?int $organizationId): self
- {
- $this->organizationId = $organizationId;
- return $this;
- }
- public function getPersonId(): ?int
- {
- return $this->personId;
- }
- public function setPersonId(?int $personId): self
- {
- $this->personId = $personId;
- return $this;
- }
- public function getUsername(): ?string
- {
- return $this->username;
- }
- public function setUsername(?string $username): self
- {
- $this->username = $username;
- return $this;
- }
- public function getName(): ?string
- {
- return $this->name;
- }
- public function setName(?string $name): self
- {
- $this->name = $name;
- return $this;
- }
- public function getGivenName(): ?string
- {
- return $this->givenName;
- }
- public function setGivenName(?string $givenName): self
- {
- $this->givenName = $givenName;
- return $this;
- }
- public function getFullName(): ?string
- {
- return $this->fullName;
- }
- public function setFullName(?string $fullName): self
- {
- $this->fullName = $fullName;
- return $this;
- }
- }
|