浏览代码

fix Parameters new subdomains fields config

Olivier Massot 3 年之前
父节点
当前提交
7afe73865f
共有 1 个文件被更改,包括 33 次插入3 次删除
  1. 33 3
      src/Entity/Organization/Parameters.php

+ 33 - 3
src/Entity/Organization/Parameters.php

@@ -160,9 +160,8 @@ class Parameters
     #[ORM\Column(options: ['default' => false])]
     private bool $sendAttendanceSms = false;
 
-    #[ORM\OneToOne( mappedBy: 'parameters', targetEntity: Subdomain::class)]
-    #[ApiSubresource]
-    private Subdomain $activeSubdomain;
+    #[ORM\OneToOne(targetEntity: Subdomain::class, cascade: ['persist'], fetch: 'EAGER')]
+    private ?Subdomain $activeSubdomain = null;
 
     #[ORM\OneToMany( mappedBy: 'parameters', targetEntity: Subdomain::class)]
     #[ApiSubresource]
@@ -635,4 +634,35 @@ class Parameters
 
         return $this;
     }
+
+    public function getActiveSubdomain(): ?Subdomain
+    {
+        return $this->activeSubdomain;
+    }
+
+    public function setActiveSubdomain(?Subdomain $activeSubdomain): self
+    {
+        $this->activeSubdomain = $activeSubdomain;
+
+        return $this;
+    }
+
+    public function getSubdomains(): Collection
+    {
+        return $this->subdomains;
+    }
+
+    public function addSubdomain($subdomain): self
+    {
+        $subdomain->setParameters($this);
+        $this->subdomains[] = $subdomain;
+        return $this;
+    }
+
+    public function removeSubdomain($subdomain): self
+    {
+        $subdomain->setParameters(null);
+        $this->subdomains->removeElement($subdomain);
+        return $this;
+    }
 }