src/Entity/Gos/CalendarEventKind.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Gos;
  3. use App\Repository\Gos\CalendarEventKindRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Gedmo\Mapping\Annotation as Gedmo;
  8. /**
  9.  * @ORM\Entity(repositoryClass=CalendarEventKindRepository::class)
  10.  * @ORM\HasLifecycleCallbacks()
  11.  */
  12. class CalendarEventKind
  13. {
  14.     /**
  15.      * @ORM\Id
  16.      * @ORM\GeneratedValue
  17.      * @ORM\Column(type="integer")
  18.      */
  19.     private $id;
  20.     /**
  21.      * @ORM\Column(type="string", length=255)
  22.      */
  23.     private $name;
  24.     /**
  25.      * @ORM\Column(type="string", length=191, unique=true)
  26.      * @Gedmo\Slug(fields={"name"})
  27.      */
  28.     private $slug;
  29.     /**
  30.      * @ORM\Column(type="string", length=255)
  31.      */
  32.     private $color;
  33.     /**
  34.      * @ORM\Column(type="datetime")
  35.      */
  36.     private $createdAt;
  37.     /**
  38.      * @ORM\Column(type="datetime", nullable=true)
  39.      */
  40.     private $updatedAt;
  41.     /**
  42.      * @ORM\OneToMany(targetEntity=CalendarEvent::class, mappedBy="calendarEventKind")
  43.      */
  44.     private $calendarEvents;
  45.     public function __construct()
  46.     {
  47.         $this->calendarEvents = new ArrayCollection();
  48.     }
  49.     /** @ORM\PrePersist() */
  50.     public function onPrePersist()
  51.     {
  52.         $this->createdAt = new \DateTime();
  53.     }
  54.     /** @ORM\PreUpdate() */
  55.     public function onPreUpdate()
  56.     {
  57.         $this->updatedAt = new \DateTime();
  58.     }
  59.     public function getId(): ?int
  60.     {
  61.         return $this->id;
  62.     }
  63.     public function getName(): ?string
  64.     {
  65.         return $this->name;
  66.     }
  67.     public function setName(string $name): self
  68.     {
  69.         $this->name $name;
  70.         return $this;
  71.     }
  72.     public function getSlug(): ?string
  73.     {
  74.         return $this->slug;
  75.     }
  76.     public function setSlug(string $slug): self
  77.     {
  78.         $this->slug $slug;
  79.         return $this;
  80.     }
  81.     public function getColor(): ?string
  82.     {
  83.         return $this->color;
  84.     }
  85.     public function setColor(string $color): self
  86.     {
  87.         $this->color $color;
  88.         return $this;
  89.     }
  90.     public function getCreatedAt(): ?\DateTimeInterface
  91.     {
  92.         return $this->createdAt;
  93.     }
  94.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  95.     {
  96.         $this->createdAt $createdAt;
  97.         return $this;
  98.     }
  99.     public function getUpdatedAt(): ?\DateTimeInterface
  100.     {
  101.         return $this->updatedAt;
  102.     }
  103.     public function setUpdatedAt(\DateTimeInterface $updatedAt): self
  104.     {
  105.         $this->updatedAt $updatedAt;
  106.         return $this;
  107.     }
  108.     /**
  109.      * @return Collection|CalendarEvent[]
  110.      */
  111.     public function getCalendarEvents(): Collection
  112.     {
  113.         return $this->calendarEvents;
  114.     }
  115.     public function addCalendarEvent(CalendarEvent $calendarEvent): self
  116.     {
  117.         if (!$this->calendarEvents->contains($calendarEvent)) {
  118.             $this->calendarEvents[] = $calendarEvent;
  119.             $calendarEvent->setCalendarEventKind($this);
  120.         }
  121.         return $this;
  122.     }
  123.     public function removeCalendarEvent(CalendarEvent $calendarEvent): self
  124.     {
  125.         if ($this->calendarEvents->contains($calendarEvent)) {
  126.             $this->calendarEvents->removeElement($calendarEvent);
  127.             // set the owning side to null (unless already changed)
  128.             if ($calendarEvent->getCalendarEventKind() === $this) {
  129.                 $calendarEvent->setCalendarEventKind(null);
  130.             }
  131.         }
  132.         return $this;
  133.     }
  134. }