SubdomainAvailability.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\ApiResources\Organization\Subdomain;
  4. use ApiPlatform\Metadata\ApiProperty;
  5. use ApiPlatform\Metadata\ApiResource;
  6. use ApiPlatform\Metadata\Get;
  7. use App\State\Provider\Organization\Subdomain\SubdomainAvailabilityProvider;
  8. #[ApiResource(
  9. operations: [
  10. new Get(
  11. uriTemplate: '/subdomains/is_available',
  12. security: 'is_granted("ROLE_ORGANIZATION_VIEW") or is_granted("ROLE_ORGANIZATION")',
  13. provider: SubdomainAvailabilityProvider::class
  14. ),
  15. ]
  16. )]
  17. class SubdomainAvailability
  18. {
  19. /**
  20. * Id 'bidon' ajouté par défaut pour permettre la construction
  21. * de l'IRI par api platform.
  22. */
  23. #[ApiProperty(identifier: true)]
  24. protected int $id = 0;
  25. /**
  26. * The subdomain.
  27. */
  28. private string $subdomain;
  29. /**
  30. * Is the subdomain available (not registered nor reserved).
  31. */
  32. private bool $available;
  33. public function getId(): int
  34. {
  35. return $this->id;
  36. }
  37. public function setId(int $id): void
  38. {
  39. $this->id = $id;
  40. }
  41. public function getSubdomain(): string
  42. {
  43. return $this->subdomain;
  44. }
  45. public function setSubdomain(string $subdomain): void
  46. {
  47. $this->subdomain = $subdomain;
  48. }
  49. public function isAvailable(): bool
  50. {
  51. return $this->available;
  52. }
  53. public function setAvailable(bool $available): void
  54. {
  55. $this->available = $available;
  56. }
  57. }