src/Entity/Otpusk/GeoCategory.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Otpusk;
  3. use App\Repository\Otpusk\GeoCategoryRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Entity(repositoryClass=GeoCategoryRepository::class)
  9.  */
  10. class GeoCategory
  11. {
  12.     /**
  13.      * @ORM\Id
  14.      * @ORM\GeneratedValue
  15.      * @ORM\Column(type="integer")
  16.      */
  17.     private $id;
  18.     /**
  19.      * @ORM\Column(type="string", length=1024, nullable=false)
  20.      */
  21.     private $name;
  22.     /**
  23.      * @var Collection|GeoCategoryValues[]
  24.      * @ORM\OneToMany(targetEntity="App\Entity\Otpusk\GeoCategoryValues", mappedBy="category", cascade={"persist"}, orphanRemoval=true)
  25.      */
  26.     private $values;
  27.     public function __construct()
  28.     {
  29.         $this->values = new ArrayCollection();
  30.     }
  31.     public function getId(): ?int
  32.     {
  33.         return $this->id;
  34.     }
  35.     public function getName(): string
  36.     {
  37.         return $this->name;
  38.     }
  39.     public function setName(string $name): self
  40.     {
  41.         $this->name $name;
  42.         return $this;
  43.     }
  44.     /**
  45.      * @return Collection|GeoCategoryValues[]
  46.      */
  47.     public function getValues(): Collection
  48.     {
  49.         return $this->values;
  50.     }
  51.     public function addValue(GeoCategoryValues $value): self
  52.     {
  53.         if (!$this->values->contains($value)) {
  54.             $this->values[] = $value;
  55.             $value->setSelection($this);
  56.         }
  57.         return $this;
  58.     }
  59.     public function removeValue(GeoCategoryValues $value): self
  60.     {
  61.         if ($this->values->contains($value)) {
  62.             $this->values->removeElement($value);
  63.             if ($value->getSelection() === $this) {
  64.                 $value->setSelection(null);
  65.             }
  66.         }
  67.         return $this;
  68.     }
  69.     public function __toString()
  70.     {
  71.         return $this->getName();
  72.     }
  73. }