src/Entity/App/App.php line 10

Open in your IDE?
  1. <?php
  2. namespace App\Entity\App;
  3. use App\Repository\App\AppRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Symfony\Component\Security\Core\User\UserInterface;
  6. #[ORM\Entity(repositoryClass: AppRepository::class)]
  7. class App implements UserInterface
  8. {
  9. #[ORM\Id]
  10. #[ORM\GeneratedValue]
  11. #[ORM\Column(type: 'integer')]
  12. private ?int $id = null;
  13. #[ORM\Column(type: 'string', length: 31)]
  14. private ?string $label = null;
  15. #[ORM\Column(type: 'string', length: 31, unique: true)]
  16. private ?string $queueName = null;
  17. #[ORM\Column(type: 'string', length: 36, unique: true)]
  18. private ?string $secret = null;
  19. #[ORM\Column(type: 'string', length: 255)]
  20. private ?string $url = null;
  21. // #[ORM\Column(type: 'string', length: 255)]
  22. // private ?string $baseUrl = null;
  23. public function getId(): ?int
  24. {
  25. return $this->id;
  26. }
  27. public function getLabel(): ?string
  28. {
  29. return $this->label;
  30. }
  31. public function setLabel(string $label): static
  32. {
  33. $this->label = $label;
  34. return $this;
  35. }
  36. public function getQueueName(): ?string
  37. {
  38. return $this->queueName;
  39. }
  40. public function setQueueName(?string $queueName): static
  41. {
  42. $this->queueName = $queueName;
  43. return $this;
  44. }
  45. public function getSecret(): ?string
  46. {
  47. return $this->secret;
  48. }
  49. public function setSecret(string $secret): static
  50. {
  51. $this->secret = $secret;
  52. return $this;
  53. }
  54. public function getRoles(): array
  55. {
  56. return [
  57. 'ROLE_USER',
  58. ];
  59. }
  60. public function getPassword(): ?string
  61. {
  62. return null;
  63. }
  64. public function getSalt(): void
  65. {
  66. }
  67. public function eraseCredentials(): void
  68. {
  69. }
  70. public function getUserIdentifier(): string
  71. {
  72. return (string) $this->getLabel();
  73. }
  74. public function getUsername(): string
  75. {
  76. return $this->getUsername();
  77. }
  78. public function getUrl(): ?string
  79. {
  80. return rtrim((string) $this->url, '/').'/';
  81. }
  82. public function setUrl(?string $url): static
  83. {
  84. $this->url = rtrim((string) $url, '/').'/';
  85. return $this;
  86. }
  87. public function getScheme(): ?string
  88. {
  89. if (null === $url = $this->getUrl()) {
  90. return null;
  91. }
  92. return parse_url($url, PHP_URL_SCHEME) ?? 'http';
  93. }
  94. public function getPort(): ?int
  95. {
  96. if (null === $url = $this->getUrl()) {
  97. return null;
  98. }
  99. if (null === $port = parse_url($url, PHP_URL_PORT)) {
  100. $port = ('https' === $this->getScheme()) ? 443 : 80;
  101. }
  102. return $port;
  103. }
  104. public function getHost(): ?string
  105. {
  106. if (null === $url = $this->getUrl()) {
  107. return null;
  108. }
  109. return parse_url($url, PHP_URL_HOST) ?? null;
  110. }
  111. public function getBaseUri(): ?string
  112. {
  113. if (null === $url = $this->getUrl()) {
  114. return null;
  115. }
  116. $url = rtrim($url, '/');
  117. if (str_contains($url, '/core')) {
  118. return str_replace('/core', '', $url);
  119. }
  120. return $url;
  121. }
  122. }