src/Entity/Organization.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Symfony\Component\Serializer\Annotation\Groups;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClass'App\Repository\OrganizationRepository')]
  8. class Organization
  9. {
  10.     #[Groups(['LogService'])]
  11.     #[ORM\Id]
  12.     #[ORM\GeneratedValue]
  13.     #[ORM\Column(type'integer')]
  14.     private $id;
  15.     #[Groups(['LogService'])]
  16.     #[ORM\ManyToOne(targetEntity'App\Entity\Office'inversedBy'organizations')]
  17.     #[ORM\JoinColumn(nullablefalse)]
  18.     private $office;
  19.     #[Groups(['LogService'])]
  20.     #[ORM\ManyToOne(targetEntity'App\Entity\User'inversedBy'organizations')]
  21.     private $user;
  22.     #[Groups(['LogService'])]
  23.     #[ORM\Column(type'string'length32nullabletrue)]
  24.     private $title;
  25.     #[Groups(['LogService'])]
  26.     #[ORM\ManyToOne(targetEntity'App\Entity\Department'inversedBy'organizations')]
  27.     private $department;
  28.     #[Groups(['LogService'])]
  29.     #[ORM\Column(type'boolean'nullabletrue)]
  30.     private $isGroup;
  31.     #[Groups(['LogService'])]
  32.     #[ORM\ManyToOne(targetEntity'App\Entity\Organization'inversedBy'groupUsers')]
  33.     private $inGroup;
  34.     #[ORM\OneToMany(targetEntity'App\Entity\Organization'mappedBy'inGroup')]
  35.     private $groupUsers;
  36.     #[Groups(['LogService'])]
  37.     #[ORM\ManyToOne(targetEntity'App\Entity\Organization'inversedBy'supervisorChilds')]
  38.     private $supervisor;
  39.     #[ORM\OneToMany(targetEntity'App\Entity\Organization'mappedBy'supervisor')]
  40.     private $supervisorChilds;
  41.     #[Groups(['LogService'])]
  42.     #[ORM\Column(type'integer')]
  43.     private $ordering 0;
  44.     #[ORM\Column(type'datetime'nullabletrue)]
  45.     private $updatedAt;
  46.     public function __construct()
  47.     {
  48.         $this->groupUsers = new ArrayCollection();
  49.         $this->supervisorChilds = new ArrayCollection();
  50.     }
  51.     public function getId(): ?int
  52.     {
  53.         return $this->id;
  54.     }
  55.     public function getOffice(): ?Office
  56.     {
  57.         return $this->office;
  58.     }
  59.     public function setOffice(?Office $office): self
  60.     {
  61.         $this->office $office;
  62.         return $this;
  63.     }
  64.     public function getUser(): ?User
  65.     {
  66.         return $this->user;
  67.     }
  68.     public function setUser(?User $user): self
  69.     {
  70.         $this->user $user;
  71.         return $this;
  72.     }
  73.     public function getTitle(): ?string
  74.     {
  75.         return $this->title;
  76.     }
  77.     public function setTitle(?string $title): self
  78.     {
  79.         $this->title $title;
  80.         return $this;
  81.     }
  82.     public function getDepartment(): ?Department
  83.     {
  84.         return $this->department;
  85.     }
  86.     public function setDepartment(?Department $department): self
  87.     {
  88.         $this->department $department;
  89.         return $this;
  90.     }
  91.     public function getIsGroup(): ?bool
  92.     {
  93.         return $this->isGroup;
  94.     }
  95.     public function setIsGroup(?bool $isGroup): self
  96.     {
  97.         $this->isGroup $isGroup;
  98.         return $this;
  99.     }
  100.     public function getInGroup(): ?self
  101.     {
  102.         return $this->inGroup;
  103.     }
  104.     public function setInGroup(?self $inGroup): self
  105.     {
  106.         $this->inGroup $inGroup;
  107.         return $this;
  108.     }
  109.     /**
  110.      * @return Collection|self[]
  111.      */
  112.     public function getGroupUsers(): Collection
  113.     {
  114.         return $this->groupUsers;
  115.     }
  116.     public function addGroupUser(self $groupUser): self
  117.     {
  118.         if (!$this->groupUsers->contains($groupUser)) {
  119.             $this->groupUsers[] = $groupUser;
  120.             $groupUser->setInGroup($this);
  121.         }
  122.         return $this;
  123.     }
  124.     public function removeGroupUser(self $groupUser): self
  125.     {
  126.         if ($this->groupUsers->contains($groupUser)) {
  127.             $this->groupUsers->removeElement($groupUser);
  128.             // set the owning side to null (unless already changed)
  129.             if ($groupUser->getInGroup() === $this) {
  130.                 $groupUser->setInGroup(null);
  131.             }
  132.         }
  133.         return $this;
  134.     }
  135.     public function getSupervisor(): ?self
  136.     {
  137.         return $this->supervisor;
  138.     }
  139.     public function setSupervisor(?self $supervisor): self
  140.     {
  141.         $this->supervisor $supervisor;
  142.         return $this;
  143.     }
  144.     /**
  145.      * @return Collection|self[]
  146.      */
  147.     public function getSupervisorChilds(): Collection
  148.     {
  149.         return $this->supervisorChilds;
  150.     }
  151.     public function addSupervisorChild(self $supervisorChild): self
  152.     {
  153.         if (!$this->supervisorChilds->contains($supervisorChild)) {
  154.             $this->supervisorChilds[] = $supervisorChild;
  155.             $supervisorChild->setSupervisor($this);
  156.         }
  157.         return $this;
  158.     }
  159.     public function removeSupervisorChild(self $supervisorChild): self
  160.     {
  161.         if ($this->supervisorChilds->contains($supervisorChild)) {
  162.             $this->supervisorChilds->removeElement($supervisorChild);
  163.             // set the owning side to null (unless already changed)
  164.             if ($supervisorChild->getSupervisor() === $this) {
  165.                 $supervisorChild->setSupervisor(null);
  166.             }
  167.         }
  168.         return $this;
  169.     }
  170.     public function getOrdering(): ?int
  171.     {
  172.         return $this->ordering;
  173.     }
  174.     public function setOrdering(int $ordering): self
  175.     {
  176.         $this->ordering $ordering;
  177.         return $this;
  178.     }
  179.     public function getUpdatedAt(): ?\DateTime
  180.     {
  181.         return $this->updatedAt;
  182.     }
  183.     public function setUpdatedAt(?\DateTime $updatedAt): self
  184.     {
  185.         $this->updatedAt $updatedAt;
  186.         return $this;
  187.     }
  188.     public function organizationTitle() {
  189.         if($this->user->getPersonalInfo()->getJobTitle() != null){ // For transitioning
  190.             return $this->user->getPersonalInfo()->getJobTitle();
  191.         } elseif ($this->title != null){
  192.             return $this->title;
  193.         } else {
  194.             return null;
  195.         }
  196.     }
  197. }