X-Git-Url: https://git.rapsys.eu/airbundle/blobdiff_plain/ca46631d1280ea5c387ae40b0b9ad1f77cb4e1c0..90b9c0d611ea9971ff324726816bd08bc2a783c3:/Entity/Slot.php?ds=inline diff --git a/Entity/Slot.php b/Entity/Slot.php index 116c29f..25ef3e8 100644 --- a/Entity/Slot.php +++ b/Entity/Slot.php @@ -1,16 +1,17 @@ + * (c) Raphaël Gertz * - * for the full copyright and license information, please view the license + * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Rapsys\AirBundle\Entity; +use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\ORM\Event\PreUpdateEventArgs; @@ -19,37 +20,34 @@ use Doctrine\ORM\Event\PreUpdateEventArgs; */ class Slot { /** - * @var integer + * Primary key */ - private $id; + private ?int $id = null; /** - * @var string + * Create datetime */ - protected $title; + private \DateTime $created; /** - * @var \DateTime + * Update datetime */ - private $created; + private \DateTime $updated; /** - * @var \DateTime + * Sessions collection */ - private $updated; - - /** - * @var ArrayCollection - */ - private $sessions; + private Collection $sessions; /** * Constructor */ - public function __construct() { + public function __construct(private string $title) { //Set defaults $this->created = new \DateTime('now'); $this->updated = new \DateTime('now'); + + //Set collections $this->sessions = new ArrayCollection(); } @@ -58,7 +56,7 @@ class Slot { * * @return integer */ - public function getId(): int { + public function getId(): ?int { return $this->id; } @@ -164,7 +162,7 @@ class Slot { */ public function preUpdate(PreUpdateEventArgs $eventArgs) { //Check that we have a slot instance - if (($slot = $eventArgs->getEntity()) instanceof Slot) { + if (($slot = $eventArgs->getObject()) instanceof Slot) { //Set updated value $slot->setUpdated(new \DateTime('now')); }