SubdomainAvailability.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. * @var int
  24. */
  25. #[ApiProperty(identifier: true)]
  26. protected int $id = 0;
  27. /**
  28. * The subdomain
  29. * @var string
  30. */
  31. private string $subdomain;
  32. /**
  33. * Is the subdomain available (not registered nor reserved)
  34. * @var bool
  35. */
  36. private bool $available;
  37. /**
  38. * @return int
  39. */
  40. public function getId(): int
  41. {
  42. return $this->id;
  43. }
  44. /**
  45. * @param int $id
  46. */
  47. public function setId(int $id): void
  48. {
  49. $this->id = $id;
  50. }
  51. /**
  52. * @return string
  53. */
  54. public function getSubdomain(): string
  55. {
  56. return $this->subdomain;
  57. }
  58. /**
  59. * @param string $subdomain
  60. */
  61. public function setSubdomain(string $subdomain): void
  62. {
  63. $this->subdomain = $subdomain;
  64. }
  65. /**
  66. * @return bool
  67. */
  68. public function isAvailable(): bool
  69. {
  70. return $this->available;
  71. }
  72. /**
  73. * @param bool $available
  74. */
  75. public function setAvailable(bool $available): void
  76. {
  77. $this->available = $available;
  78. }
  79. }