|
|
@@ -0,0 +1,83 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace App\Entity\Organization;
|
|
|
+
|
|
|
+use App\Repository\Organization\SubdomainRepository;
|
|
|
+use Doctrine\ORM\Mapping as ORM;
|
|
|
+use ApiPlatform\Core\Annotation\ApiResource;
|
|
|
+
|
|
|
+/**
|
|
|
+ * Sous-domaine enregistré par une organisation
|
|
|
+ */
|
|
|
+#[ApiResource(
|
|
|
+ itemOperations: [
|
|
|
+ 'get' => [
|
|
|
+ 'security' => '(is_granted("ROLE_ORGANIZATION_VIEW") or is_granted("ROLE_ORGANIZATION")) and object.getOrganization().getId() == user.getOrganization().getId()'
|
|
|
+ ],
|
|
|
+ 'put' => [
|
|
|
+ 'security' => 'is_granted("ROLE_ORGANIZATION") and object.getOrganization().getId() == user.getOrganization().getId()'
|
|
|
+ ]
|
|
|
+ ]
|
|
|
+)]
|
|
|
+#[ORM\Entity(repositoryClass: SubdomainRepository::class)]
|
|
|
+class Subdomain
|
|
|
+{
|
|
|
+ #[ORM\Id]
|
|
|
+ #[ORM\Column]
|
|
|
+ #[ORM\GeneratedValue]
|
|
|
+ private ?int $id = null;
|
|
|
+
|
|
|
+ #[ORM\ManyToOne(inversedBy: 'subdomains')]
|
|
|
+ private Parameters $parameters;
|
|
|
+
|
|
|
+ #[ORM\Column(length: 60, nullable: false)]
|
|
|
+ private string $subdomain;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @return int|null
|
|
|
+ */
|
|
|
+ public function getId(): ?int
|
|
|
+ {
|
|
|
+ return $this->id;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param int|null $id
|
|
|
+ */
|
|
|
+ public function setId(?int $id): void
|
|
|
+ {
|
|
|
+ $this->id = $id;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @return Parameters
|
|
|
+ */
|
|
|
+ public function getParameters(): Parameters
|
|
|
+ {
|
|
|
+ return $this->parameters;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param Parameters $parameters
|
|
|
+ */
|
|
|
+ public function setParameters(Parameters $parameters): void
|
|
|
+ {
|
|
|
+ $this->parameters = $parameters;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @return string
|
|
|
+ */
|
|
|
+ public function getSubdomain(): string
|
|
|
+ {
|
|
|
+ return $this->subdomain;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param string $subdomain
|
|
|
+ */
|
|
|
+ public function setSubdomain(string $subdomain): void
|
|
|
+ {
|
|
|
+ $this->subdomain = $subdomain;
|
|
|
+ }
|
|
|
+}
|