| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- <?php
- declare(strict_types=1);
- namespace App\ApiResources\Access;
- use ApiPlatform\Metadata\ApiProperty;
- use ApiPlatform\Metadata\ApiResource;
- use ApiPlatform\Metadata\Get;
- use ApiPlatform\Metadata\Put;
- use App\ApiResources\ApiResourcesInterface;
- use App\State\Processor\Access\AdminAccessProcessor;
- use App\State\Provider\Access\AdminAccessProvider;
- use Symfony\Component\Validator\Constraints as Assert;
- /**
- * Classe resource qui contient les champs d'un compte admin.
- */
- #[ApiResource(
- operations: [
- new Get(
- uriTemplate: '/admin-access/{id}',
- defaults: ['id' => 0]
- ),
- new Put(
- uriTemplate: '/admin-access/{id}',
- defaults: ['id' => 0],
- security: '(is_granted("ROLE_ADMIN_CORE") and object.getOrganizationId() == user.getOrganization().getId() )'
- ),
- ],
- provider: AdminAccessProvider::class,
- processor : AdminAccessProcessor::class
- )]
- class AdminAccess implements ApiResourcesInterface
- {
- #[ApiProperty(identifier: true)]
- public ?int $id = null;
- private int $organizationId;
- private ?string $username = null;
- #[Assert\Email(message: 'invalid-email-format', mode: 'strict')]
- private ?string $email = 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 getUsername(): ?string
- {
- return $this->username;
- }
- public function setUsername(?string $username): self
- {
- $this->username = $username;
- return $this;
- }
- public function getEmail(): ?string
- {
- return $this->email;
- }
- public function setEmail(?string $email): self
- {
- $this->email = $email;
- return $this;
- }
- }
|