src/Entity/TaxonomyValue.php line 11

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\TaxonomyValueRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClassTaxonomyValueRepository::class)]
  8. class TaxonomyValue
  9. {
  10.     #[ORM\Id]
  11.     #[ORM\GeneratedValue]
  12.     #[ORM\Column]
  13.     private ?int $id null;
  14.     #[ORM\Column(length255)]
  15.     private ?string $code null;
  16.     #[ORM\Column(length255nullabletrue)]
  17.     private ?string $label null;
  18.     #[ORM\ManyToOne(inversedBy'taxonomy')]
  19.     #[ORM\JoinColumn(nullablefalse)]
  20.     private ?Taxonomy $taxonomy null;
  21.     #[ORM\ManyToMany(targetEntityEvents::class, mappedBy'areaTematica')]
  22.     private Collection $events;
  23.     public function __construct()
  24.     {
  25.         $this->events = new ArrayCollection();
  26.     }
  27.     public function __toString(): string
  28.     {
  29.         return (string) ($this->getlabel() ?: $this->getcode() ?: '');
  30.     }
  31.     public function getId(): ?int
  32.     {
  33.         return $this->id;
  34.     }
  35.     public function getcode(): ?string
  36.     {
  37.         return $this->code;
  38.     }
  39.     public function setcode(string $code): static
  40.     {
  41.         $this->code $code;
  42.         return $this;
  43.     }
  44.     public function getlabel(): ?string
  45.     {
  46.         return $this->label;
  47.     }
  48.     public function setlabel(?string $label): static
  49.     {
  50.         $this->label $label;
  51.         return $this;
  52.     }
  53.     public function getTaxonomy(): ?Taxonomy
  54.     {
  55.         return $this->taxonomy;
  56.     }
  57.     public function setTaxonomy(?Taxonomy $taxonomy): static
  58.     {
  59.         $this->taxonomy $taxonomy;
  60.         return $this;
  61.     }
  62.     /**
  63.      * @return Collection<int, Events>
  64.      */
  65.     public function getEvents(): Collection
  66.     {
  67.         return $this->events;
  68.     }
  69.     public function addEvent(Events $event): static
  70.     {
  71.         if (!$this->events->contains($event)) {
  72.             $this->events->add($event);
  73.             $event->addAreaTematica($this);
  74.         }
  75.         return $this;
  76.     }
  77.     public function removeEvent(Events $event): static
  78.     {
  79.         if ($this->events->removeElement($event)) {
  80.             $event->removeAreaTematica($this);
  81.         }
  82.         return $this;
  83.     }
  84. }