src/Entity/EventType.php line 13

  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use App\Repository\EventTypeRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Entity(repositoryClassEventTypeRepository::class)]
  9. #[ApiResource]
  10. class EventType
  11. {
  12.     #[ORM\Id]
  13.     #[ORM\GeneratedValue]
  14.     #[ORM\Column]
  15.     private ?int $id null;
  16.     #[ORM\Column(length50)]
  17.     private ?string $name null;
  18.     #[ORM\OneToMany(mappedBy'eventType'targetEntityEvent::class, orphanRemovaltrue)]
  19.     private Collection $events;
  20.     public function __construct()
  21.     {
  22.         $this->events = new ArrayCollection();
  23.     }
  24.     public function getId(): ?int
  25.     {
  26.         return $this->id;
  27.     }
  28.     public function getName(): ?string
  29.     {
  30.         return $this->name;
  31.     }
  32.     public function setName(string $name): self
  33.     {
  34.         $this->name $name;
  35.         return $this;
  36.     }
  37.     /**
  38.      * @return Collection<int, Event>
  39.      */
  40.     public function getEvents(): Collection
  41.     {
  42.         return $this->events;
  43.     }
  44.     public function addEvent(Event $event): self
  45.     {
  46.         if (!$this->events->contains($event)) {
  47.             $this->events->add($event);
  48.             $event->setEventType($this);
  49.         }
  50.         return $this;
  51.     }
  52.     public function removeEvent(Event $event): self
  53.     {
  54.         if ($this->events->removeElement($event)) {
  55.             // set the owning side to null (unless already changed)
  56.             if ($event->getEventType() === $this) {
  57.                 $event->setEventType(null);
  58.             }
  59.         }
  60.         return $this;
  61.     }
  62. }