src/Entity/ServiceSectionGroup.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Enum\AssessmentDirectionCode;
  4. use App\Repository\ServiceSectionGroupRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. /**
  9.  * @ORM\Entity(repositoryClass=ServiceSectionGroupRepository::class)
  10.  */
  11. class ServiceSectionGroup
  12. {
  13.     public const LABELS = [
  14.         'Оценка для Нотариальных действий' => 'Нотариальные действия',
  15.         'Оценка по месту востребования'    => 'По месту востребования',
  16.     ];
  17.     /**
  18.      * @ORM\Id
  19.      * @ORM\GeneratedValue
  20.      * @ORM\Column(type="integer")
  21.      */
  22.     private $id;
  23.     /**
  24.      * @ORM\Column(type="string", length=255)
  25.      */
  26.     private $name;
  27.     /**
  28.      * @ORM\Column(type="integer")
  29.      */
  30.     private $sortNumber;
  31.     /**
  32.      * @ORM\OneToMany(targetEntity=ServiceSection::class, mappedBy="serviceSectionGroup")
  33.      */
  34.     private $sections;
  35.     /**
  36.      * @ORM\Column(type="array")
  37.      */
  38.     private $roles = [];
  39.     /**
  40.      * @ORM\Column(type="string", length=255)
  41.      */
  42.     private $domain;
  43.     /**
  44.      * @ORM\Column(type="string", length=255, nullable=false)
  45.      */
  46.     private string $code;
  47.     /**
  48.      * @ORM\ManyToOne(targetEntity=Service::class, inversedBy="serviceSectionGroups")
  49.      * @ORM\JoinColumn(nullable=false)
  50.      */
  51.     private Service $service;
  52.     /**
  53.      * @ORM\Column(type="boolean", nullable=true)
  54.      */
  55.     private ?bool $isEnabled true;
  56.     public function __construct()
  57.     {
  58.         $this->sections = new ArrayCollection();
  59.     }
  60.     public function getId(): ?int
  61.     {
  62.         return $this->id;
  63.     }
  64.     public function getName(): ?string
  65.     {
  66.         return $this->name;
  67.     }
  68.     public function setName(string $name): self
  69.     {
  70.         $this->name $name;
  71.         return $this;
  72.     }
  73.     public function getSortNumber(): ?int
  74.     {
  75.         return $this->sortNumber;
  76.     }
  77.     public function setSortNumber(int $sortNumber): self
  78.     {
  79.         $this->sortNumber $sortNumber;
  80.         return $this;
  81.     }
  82.     /**
  83.      * @return Collection|ServiceSection[]
  84.      */
  85.     public function getSections(): Collection
  86.     {
  87.         return $this->sections;
  88.     }
  89.     public function addSection(ServiceSection $section): self
  90.     {
  91.         if (!$this->sections->contains($section)) {
  92.             $this->sections[] = $section;
  93.             $section->setServiceSectionGroup($this);
  94.         }
  95.         return $this;
  96.     }
  97.     public function removeSection(ServiceSection $section): self
  98.     {
  99.         if ($this->sections->contains($section)) {
  100.             $this->sections->removeElement($section);
  101.             // set the owning side to null (unless already changed)
  102.             if ($section->getServiceSectionGroup() === $this) {
  103.                 $section->setServiceSectionGroup(null);
  104.             }
  105.         }
  106.         return $this;
  107.     }
  108.     public function getRoles(): ?array
  109.     {
  110.         return $this->roles;
  111.     }
  112.     public function setRoles(array $roles): self
  113.     {
  114.         $this->roles $roles;
  115.         return $this;
  116.     }
  117.     public function getDomain(): ?string
  118.     {
  119.         return $this->domain;
  120.     }
  121.     public function setDomain(string $domain): self
  122.     {
  123.         $this->domain $domain;
  124.         return $this;
  125.     }
  126.     public function getCode(): AssessmentDirectionCode
  127.     {
  128.         return AssessmentDirectionCode::from($this->code);
  129.     }
  130.     public function setCode(AssessmentDirectionCode $code): self
  131.     {
  132.         $this->code $code->value;
  133.         return $this;
  134.     }
  135.     public function getService(): Service
  136.     {
  137.         return $this->service;
  138.     }
  139.     public function setService(Service $service): self
  140.     {
  141.         $this->service $service;
  142.         return $this;
  143.     }
  144.     public function isEnabled(): bool
  145.     {
  146.         return (bool)$this->isEnabled;
  147.     }
  148.     public function setIsEnabled(bool $isEnabled): self
  149.     {
  150.         $this->isEnabled $isEnabled;
  151.         return $this;
  152.     }
  153.     public function getLabel(): string
  154.     {
  155.         return static::LABELS[$this->name] ?? '';
  156.     }
  157. }