-<?php
+<?php declare(strict_types=1);
+
+/*
+ * This file is part of the Rapsys AirBundle package.
+ *
+ * (c) Raphaël Gertz <symfony@rapsys.eu>
+ *
+ * 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\ORM\Event\PreUpdateEventArgs;
+
/**
* Application
*/
class Application {
/**
- * @var integer
+ * Primary key
+ */
+ private ?int $id = null;
+
+ /**
+ * Dance instance
+ */
+ private Dance $dance;
+
+ /**
+ * Score
*/
- private $id;
+ private ?float $score = null;
/**
- * @var float
+ * Cancel datetime
*/
- private $score;
+ private ?\DateTime $canceled = null;
/**
- * @var \DateTime
+ * Create datetime
*/
- private $canceled;
+ private \DateTime $created;
/**
- * @var \DateTime
+ * Update datetime
*/
- private $created;
+ private \DateTime $updated;
/**
- * @var \DateTime
+ * Session instance
*/
- private $updated;
+ private $session = null;
/**
- * @var \Rapsys\AirBundle\Entity\Session
+ * User instance
*/
- private $session;
+ private $user = null;
/**
- * @var \Rapsys\AirBundle\Entity\User
+ * Constructor
*/
- private $user;
+ public function __construct() {
+ //Set defaults
+ $this->created = new \DateTime('now');
+ $this->updated = new \DateTime('now');
+ }
/**
* Get id
*
* @return integer
*/
- public function getId() {
+ public function getId(): ?int {
return $this->id;
}
+ /**
+ * Set dance
+ *
+ * @param Dance $dance
+ *
+ * @return Application
+ */
+ public function setDance(Dance $dance): Application {
+ $this->dance = $dance;
+
+ return $this;
+ }
+
+ /**
+ * Get dance
+ *
+ * @return Dance
+ */
+ public function getDance(): Dance {
+ return $this->dance;
+ }
+
/**
* Set score
*
*
* @return Application
*/
- public function setScore($score) {
+ public function setScore(?float $score): Application {
$this->score = $score;
return $this;
*
* @return float
*/
- public function getScore() {
+ public function getScore(): ?float {
return $this->score;
}
*
* @return Application
*/
- public function setCanceled($canceled) {
+ public function setCanceled(?\DateTime $canceled): Application {
$this->canceled = $canceled;
return $this;
*
* @return \DateTime
*/
- public function getCanceled() {
+ public function getCanceled(): ?\DateTime {
return $this->canceled;
}
*
* @return Application
*/
- public function setCreated($created) {
+ public function setCreated(\DateTime $created): Application {
$this->created = $created;
return $this;
*
* @return \DateTime
*/
- public function getCreated() {
+ public function getCreated(): \DateTime {
return $this->created;
}
*
* @return Application
*/
- public function setUpdated($updated) {
+ public function setUpdated(\DateTime $updated): Application {
$this->updated = $updated;
return $this;
*
* @return \DateTime
*/
- public function getUpdated() {
+ public function getUpdated(): \DateTime {
return $this->updated;
}
/**
* Set session
*
- * @param \Rapsys\AirBundle\Entity\Session $session
+ * @param Session $session
*
* @return Application
*/
- public function setSession(\Rapsys\AirBundle\Entity\Session $session = null) {
+ public function setSession(Session $session): Application {
$this->session = $session;
return $this;
/**
* Get session
*
- * @return \Rapsys\AirBundle\Entity\Session
+ * @return Session
*/
- public function getSession() {
+ public function getSession(): Session {
return $this->session;
}
/**
* Set user
*
- * @param \Rapsys\AirBundle\Entity\User $user
+ * @param User $user
*
* @return Application
*/
- public function setUser(\Rapsys\AirBundle\Entity\User $user = null) {
+ public function setUser(User $user): Application {
$this->user = $user;
return $this;
/**
* Get user
*
- * @return \Rapsys\AirBundle\Entity\User
+ * @return User
*/
- public function getUser() {
+ public function getUser(): User {
return $this->user;
}
+
+ /**
+ * {@inheritdoc}
+ */
+ public function preUpdate(PreUpdateEventArgs $eventArgs) {
+ //Check that we have an application instance
+ if (($application = $eventArgs->getObject()) instanceof Application) {
+ //Set updated value
+ $application->setUpdated(new \DateTime('now'));
+ }
+ }
}