src/Entity/Institution.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  7. /**
  8.  * Institution
  9.  *
  10.  * @ORM\Table(name="institution")
  11.  * @ORM\Entity
  12.  * @UniqueEntity(fields={"name"}, message="There is already this office name")
  13.  */
  14. class Institution
  15. {
  16.     public const FEATURE_USED_RINGS_SUMMARY 'ring_register_used_rings_summary';
  17.     public const FEATURE_RECAPTURES_SUMMARY 'ring_register_recaptures_summary';
  18.     public const FEATURE_ADVANCED_SPECIAL_MARKS 'ring_register_advanced_special_marks';
  19.     public const FEATURE_LOCATION_MAP 'ring_register_location_map';
  20.     public const FEATURE_SUMMARY_INFO_LINKS 'ring_register_summary_info_links';
  21.     public const FEATURE_BULK_DELETE 'ring_register_bulk_delete';
  22.     public const FEATURE_MULTI_PROJECT_REGISTER 'ring_register_multi_project';
  23.     public const FEATURE_WORKING_SHIFT_BULK_DELETE 'working_shift_bulk_delete';
  24.     public const FEATURE_WORKING_SHIFT_SUMMARY 'working_shift_summary';
  25.     /**
  26.      * @var int
  27.      *
  28.      * @ORM\Column(name="id", type="integer", nullable=false)
  29.      * @ORM\Id
  30.      * @ORM\GeneratedValue(strategy="IDENTITY")
  31.      */
  32.     private $id;
  33.     /**
  34.      * @var string
  35.      *
  36.      * @ORM\Column(name="name", type="string", length=500, nullable=false, unique=true)
  37.      */
  38.     private $name;
  39.     /**
  40.      * @ORM\OneToMany(targetEntity=User::class, mappedBy="institution")
  41.      */
  42.     private $users;
  43.     /**
  44.      * @ORM\Column(type="boolean")
  45.      */
  46.     private $privileges;
  47.     /**
  48.      * @ORM\OneToMany(targetEntity=Group::class, mappedBy="institution")
  49.      */
  50.     private $groups;
  51.     /**
  52.      * @ORM\OneToMany(targetEntity=Ring::class, mappedBy="institution")
  53.      */
  54.     private $rings;
  55.     /**
  56.      * @ORM\OneToMany(targetEntity=RingBatch::class, mappedBy="institution")
  57.      */
  58.     private $ring_batch;
  59.     /**
  60.      * @ORM\ManyToOne(targetEntity=Institution::class, inversedBy="institutions")
  61.      */
  62.     private $office;
  63.     /**
  64.      * @ORM\OneToMany(targetEntity=Institution::class, mappedBy="office")
  65.      */
  66.     private $institutions;
  67.     /**
  68.      * @ORM\Column(type="string", length=255, nullable=true)
  69.      */
  70.     private $image;
  71.     /**
  72.      * @ORM\Column(type="json")
  73.      */
  74.     private $featureToggles = [];
  75.     public function __construct()
  76.     {
  77.         $this->users = new ArrayCollection();
  78.         $this->groups = new ArrayCollection();
  79.         $this->rings = new ArrayCollection();
  80.         $this->institutions = new ArrayCollection();
  81.     }
  82.     public function __toString()
  83.     {
  84.         return $this->name;
  85.     }
  86.     public function getId(): ?int
  87.     {
  88.         return $this->id;
  89.     }
  90.     public function getName(): ?string
  91.     {
  92.         return $this->name;
  93.     }
  94.     public function setName(string $name): self
  95.     {
  96.         $this->name $name;
  97.         return $this;
  98.     }
  99.     /**
  100.      * @return Collection<int, User>
  101.      */
  102.     public function getUsers(): Collection
  103.     {
  104.         return $this->users;
  105.     }
  106.     public function addUser(User $user): self
  107.     {
  108.         if (!$this->users->contains($user)) {
  109.             $this->users[] = $user;
  110.             $user->setInstitution($this);
  111.         }
  112.         return $this;
  113.     }
  114.     public function removeUser(User $user): self
  115.     {
  116.         if ($this->users->removeElement($user)) {
  117.             // set the owning side to null (unless already changed)
  118.             if ($user->getInstitution() === $this) {
  119.                 $user->setInstitution(null);
  120.             }
  121.         }
  122.         return $this;
  123.     }
  124.     public function isPrivileges(): ?bool
  125.     {
  126.         return $this->privileges;
  127.     }
  128.     public function setPrivileges(bool $privileges): self
  129.     {
  130.         $this->privileges $privileges;
  131.         return $this;
  132.     }
  133.     /**
  134.      * @return Collection<int, Group>
  135.      */
  136.     public function getGroups(): Collection
  137.     {
  138.         return $this->groups;
  139.     }
  140.     public function addGroup(Group $group): self
  141.     {
  142.         if (!$this->groups->contains($group)) {
  143.             $this->groups[] = $group;
  144.             $group->setInstitution($this);
  145.         }
  146.         return $this;
  147.     }
  148.     public function removeGroup(Group $group): self
  149.     {
  150.         if ($this->groups->removeElement($group)) {
  151.             // set the owning side to null (unless already changed)
  152.             if ($group->getInstitution() === $this) {
  153.                 $group->setInstitution(null);
  154.             }
  155.         }
  156.         return $this;
  157.     }
  158.     /**
  159.      * @return Collection<int, Ring>
  160.      */
  161.     public function getRings(): Collection
  162.     {
  163.         return $this->rings;
  164.     }
  165.     public function addRing(Ring $ring): self
  166.     {
  167.         if (!$this->rings->contains($ring)) {
  168.             $this->rings[] = $ring;
  169.             $ring->setInstitution($this);
  170.         }
  171.         return $this;
  172.     }
  173.     public function removeRing(Ring $ring): self
  174.     {
  175.         if ($this->rings->removeElement($ring)) {
  176.             // set the owning side to null (unless already changed)
  177.             if ($ring->getInstitution() === $this) {
  178.                 $ring->setInstitution(null);
  179.             }
  180.         }
  181.         return $this;
  182.     }
  183.     /**
  184.      * @return Collection<int, Ring>
  185.      */
  186.     public function getRingBatch(): Collection
  187.     {
  188.         return $this->ring_batch;
  189.     }
  190.     public function addRingBatch(RingBatch $ring_batch): self
  191.     {
  192.         if (!$this->ring_batch->contains($ring_batch)) {
  193.             $this->ring_batch[] = $ring_batch;
  194.             $ring_batch->setInstitution($this);
  195.         }
  196.         return $this;
  197.     }
  198.     public function removeRingBatch(RingBatch $ring_batch): self
  199.     {
  200.         if ($this->ring_batch->removeElement($ring_batch)) {
  201.             // set the owning side to null (unless already changed)
  202.             if ($ring_batch->getInstitution() === $this) {
  203.                 $ring_batch->setInstitution(null);
  204.             }
  205.         }
  206.         return $this;
  207.     }
  208.     public function getOffice(): ?self
  209.     {
  210.         return $this->office;
  211.     }
  212.     public function setOffice(?self $office): self
  213.     {
  214.         $this->office $office;
  215.         return $this;
  216.     }
  217.     /**
  218.      * @return Collection<int, self>
  219.      */
  220.     public function getInstitutions(): Collection
  221.     {
  222.         return $this->institutions;
  223.     }
  224.     public function addInstitution(self $institution): self
  225.     {
  226.         if (!$this->institutions->contains($institution)) {
  227.             $this->institutions[] = $institution;
  228.             $institution->setOffice($this);
  229.         }
  230.         return $this;
  231.     }
  232.     public function removeInstitution(self $institution): self
  233.     {
  234.         if ($this->institutions->removeElement($institution)) {
  235.             // set the owning side to null (unless already changed)
  236.             if ($institution->getOffice() === $this) {
  237.                 $institution->setOffice(null);
  238.             }
  239.         }
  240.         return $this;
  241.     }
  242.     public function getImage(): ?string
  243.     {
  244.         return $this->image;
  245.     }
  246.     public function setImage(string $image): self
  247.     {
  248.         $this->image $image;
  249.         return $this;
  250.     }
  251.     public function getFeatureToggles(): array
  252.     {
  253.         return $this->featureToggles;
  254.     }
  255.     public function setFeatureToggles(array $featureToggles): self
  256.     {
  257.         $this->featureToggles $featureToggles;
  258.         return $this;
  259.     }
  260.     public function isFeatureEnabled(string $feature): bool
  261.     {
  262.         return ($this->featureToggles[$feature] ?? false) === true;
  263.     }
  264.     public function setFeatureEnabled(string $featurebool $enabled): self
  265.     {
  266.         $this->featureToggles[$feature] = $enabled;
  267.         return $this;
  268.     }
  269. }