1 <?php
declare(strict_types
=1);
4 * This file is part of the Rapsys AirBundle package.
6 * (c) Raphaël Gertz <symfony@rapsys.eu>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Rapsys\AirBundle\Entity
;
14 use Doctrine\Common\Collections\Collection
;
15 use Doctrine\Common\Collections\ArrayCollection
;
16 use Doctrine\ORM\Event\PreUpdateEventArgs
;
25 private ?int $id = null;
30 private \DateTime
$created;
35 private \DateTime
$updated;
40 private Collection
$sessions;
45 public function __construct(private string $title) {
47 $this->created
= new \
DateTime('now');
48 $this->updated
= new \
DateTime('now');
51 $this->sessions
= new ArrayCollection();
59 public function getId(): ?int {
66 * @param string $title
70 public function setTitle(string $title) {
71 $this->title
= $title;
81 public function getTitle(): string {
88 * @param \DateTime $created
92 public function setCreated(\DateTime
$created) {
93 $this->created
= $created;
103 public function getCreated(): \DateTime
{
104 return $this->created
;
110 * @param \DateTime $updated
114 public function setUpdated(\DateTime
$updated) {
115 $this->updated
= $updated;
125 public function getUpdated(): \DateTime
{
126 return $this->updated
;
132 * @param Session $session
136 public function addSession(Session
$session): Slot
{
137 $this->sessions
[] = $session;
145 * @param Session $session
147 public function removeSession(Session
$session): bool {
148 return $this->sessions
->removeElement($session);
154 * @return ArrayCollection
156 public function getSessions(): ArrayCollection
{
157 return $this->sessions
;
163 public function preUpdate(PreUpdateEventArgs
$eventArgs) {
164 //Check that we have a slot instance
165 if (($slot = $eventArgs->getObject()) instanceof Slot
) {
167 $slot->setUpdated(new \
DateTime('now'));
172 * Returns a string representation of the slot
176 public function __toString(): string {