<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* Institution
*
* @ORM\Table(name="institution")
* @ORM\Entity
* @UniqueEntity(fields={"name"}, message="There is already this office name")
*/
class Institution
{
public const FEATURE_USED_RINGS_SUMMARY = 'ring_register_used_rings_summary';
public const FEATURE_RECAPTURES_SUMMARY = 'ring_register_recaptures_summary';
public const FEATURE_ADVANCED_SPECIAL_MARKS = 'ring_register_advanced_special_marks';
public const FEATURE_LOCATION_MAP = 'ring_register_location_map';
public const FEATURE_SUMMARY_INFO_LINKS = 'ring_register_summary_info_links';
public const FEATURE_BULK_DELETE = 'ring_register_bulk_delete';
public const FEATURE_MULTI_PROJECT_REGISTER = 'ring_register_multi_project';
public const FEATURE_WORKING_SHIFT_BULK_DELETE = 'working_shift_bulk_delete';
public const FEATURE_WORKING_SHIFT_SUMMARY = 'working_shift_summary';
/**
* @var int
*
* @ORM\Column(name="id", type="integer", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=500, nullable=false, unique=true)
*/
private $name;
/**
* @ORM\OneToMany(targetEntity=User::class, mappedBy="institution")
*/
private $users;
/**
* @ORM\Column(type="boolean")
*/
private $privileges;
/**
* @ORM\OneToMany(targetEntity=Group::class, mappedBy="institution")
*/
private $groups;
/**
* @ORM\OneToMany(targetEntity=Ring::class, mappedBy="institution")
*/
private $rings;
/**
* @ORM\OneToMany(targetEntity=RingBatch::class, mappedBy="institution")
*/
private $ring_batch;
/**
* @ORM\ManyToOne(targetEntity=Institution::class, inversedBy="institutions")
*/
private $office;
/**
* @ORM\OneToMany(targetEntity=Institution::class, mappedBy="office")
*/
private $institutions;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $image;
/**
* @ORM\Column(type="json")
*/
private $featureToggles = [];
public function __construct()
{
$this->users = new ArrayCollection();
$this->groups = new ArrayCollection();
$this->rings = new ArrayCollection();
$this->institutions = new ArrayCollection();
}
public function __toString()
{
return $this->name;
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
/**
* @return Collection<int, User>
*/
public function getUsers(): Collection
{
return $this->users;
}
public function addUser(User $user): self
{
if (!$this->users->contains($user)) {
$this->users[] = $user;
$user->setInstitution($this);
}
return $this;
}
public function removeUser(User $user): self
{
if ($this->users->removeElement($user)) {
// set the owning side to null (unless already changed)
if ($user->getInstitution() === $this) {
$user->setInstitution(null);
}
}
return $this;
}
public function isPrivileges(): ?bool
{
return $this->privileges;
}
public function setPrivileges(bool $privileges): self
{
$this->privileges = $privileges;
return $this;
}
/**
* @return Collection<int, Group>
*/
public function getGroups(): Collection
{
return $this->groups;
}
public function addGroup(Group $group): self
{
if (!$this->groups->contains($group)) {
$this->groups[] = $group;
$group->setInstitution($this);
}
return $this;
}
public function removeGroup(Group $group): self
{
if ($this->groups->removeElement($group)) {
// set the owning side to null (unless already changed)
if ($group->getInstitution() === $this) {
$group->setInstitution(null);
}
}
return $this;
}
/**
* @return Collection<int, Ring>
*/
public function getRings(): Collection
{
return $this->rings;
}
public function addRing(Ring $ring): self
{
if (!$this->rings->contains($ring)) {
$this->rings[] = $ring;
$ring->setInstitution($this);
}
return $this;
}
public function removeRing(Ring $ring): self
{
if ($this->rings->removeElement($ring)) {
// set the owning side to null (unless already changed)
if ($ring->getInstitution() === $this) {
$ring->setInstitution(null);
}
}
return $this;
}
/**
* @return Collection<int, Ring>
*/
public function getRingBatch(): Collection
{
return $this->ring_batch;
}
public function addRingBatch(RingBatch $ring_batch): self
{
if (!$this->ring_batch->contains($ring_batch)) {
$this->ring_batch[] = $ring_batch;
$ring_batch->setInstitution($this);
}
return $this;
}
public function removeRingBatch(RingBatch $ring_batch): self
{
if ($this->ring_batch->removeElement($ring_batch)) {
// set the owning side to null (unless already changed)
if ($ring_batch->getInstitution() === $this) {
$ring_batch->setInstitution(null);
}
}
return $this;
}
public function getOffice(): ?self
{
return $this->office;
}
public function setOffice(?self $office): self
{
$this->office = $office;
return $this;
}
/**
* @return Collection<int, self>
*/
public function getInstitutions(): Collection
{
return $this->institutions;
}
public function addInstitution(self $institution): self
{
if (!$this->institutions->contains($institution)) {
$this->institutions[] = $institution;
$institution->setOffice($this);
}
return $this;
}
public function removeInstitution(self $institution): self
{
if ($this->institutions->removeElement($institution)) {
// set the owning side to null (unless already changed)
if ($institution->getOffice() === $this) {
$institution->setOffice(null);
}
}
return $this;
}
public function getImage(): ?string
{
return $this->image;
}
public function setImage(string $image): self
{
$this->image = $image;
return $this;
}
public function getFeatureToggles(): array
{
return $this->featureToggles;
}
public function setFeatureToggles(array $featureToggles): self
{
$this->featureToggles = $featureToggles;
return $this;
}
public function isFeatureEnabled(string $feature): bool
{
return ($this->featureToggles[$feature] ?? false) === true;
}
public function setFeatureEnabled(string $feature, bool $enabled): self
{
$this->featureToggles[$feature] = $enabled;
return $this;
}
}