src/Entity/Calendar.php line 12

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\CalendarRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Gedmo\Timestampable\Traits\TimestampableEntity;
  8. #[ORM\Entity(repositoryClassCalendarRepository::class)]
  9. class Calendar
  10. {
  11.     use TimestampableEntity;
  12.     #[ORM\Id]
  13.     #[ORM\GeneratedValue]
  14.     #[ORM\Column]
  15.     private ?int $id null;
  16.     #[ORM\Column(length255)]
  17.     private ?string $name null;
  18.     #[ORM\OneToMany(mappedBy'calendar'targetEntityPeriod::class)]
  19.     private Collection $periods;
  20.     public function __construct()
  21.     {
  22.         $this->periods = 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, Period>
  39.      */
  40.     public function getPeriods(): Collection
  41.     {
  42.         return $this->periods;
  43.     }
  44.     public function addPeriod(Period $period): self
  45.     {
  46.         if (!$this->periods->contains($period)) {
  47.             $this->periods->add($period);
  48.             $period->setCalendar($this);
  49.         }
  50.         return $this;
  51.     }
  52.     public function removePeriod(Period $period): self
  53.     {
  54.         if ($this->periods->removeElement($period)) {
  55.             // set the owning side to null (unless already changed)
  56.             if ($period->getCalendar() === $this) {
  57.                 $period->setCalendar(null);
  58.             }
  59.         }
  60.         return $this;
  61.     }
  62. }