X-Git-Url: https://git.rapsys.eu/airbundle/blobdiff_plain/8bda7e198de0ed76268be5c51b24ed9eeb6af54b..refs/heads/master:/Entity/Application.php diff --git a/Entity/Application.php b/Entity/Application.php index af4d3a9..23f44bf 100644 --- a/Entity/Application.php +++ b/Entity/Application.php @@ -1,55 +1,102 @@ - + * + * 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 ?\DateTimeImmutable $canceled = null; /** - * @var \DateTime + * Create datetime */ - private $canceled; + private \DateTimeImmutable $created; /** - * @var \DateTime + * Update datetime */ - private $created; + private \DateTimeImmutable $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 \DateTimeImmutable('now'); + $this->updated = new \DateTimeImmutable('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 * @@ -57,7 +104,7 @@ class Application { * * @return Application */ - public function setScore($score) { + public function setScore(?float $score): Application { $this->score = $score; return $this; @@ -68,18 +115,18 @@ class Application { * * @return float */ - public function getScore() { + public function getScore(): ?float { return $this->score; } /** * Set canceled * - * @param \DateTime $canceled + * @param \DateTimeImmutable $canceled * * @return Application */ - public function setCanceled($canceled) { + public function setCanceled(?\DateTimeImmutable $canceled): Application { $this->canceled = $canceled; return $this; @@ -88,20 +135,20 @@ class Application { /** * Get canceled * - * @return \DateTime + * @return \DateTimeImmutable */ - public function getCanceled() { + public function getCanceled(): ?\DateTimeImmutable { return $this->canceled; } /** * Set created * - * @param \DateTime $created + * @param \DateTimeImmutable $created * * @return Application */ - public function setCreated($created) { + public function setCreated(\DateTimeImmutable $created): Application { $this->created = $created; return $this; @@ -110,20 +157,20 @@ class Application { /** * Get created * - * @return \DateTime + * @return \DateTimeImmutable */ - public function getCreated() { + public function getCreated(): \DateTimeImmutable { return $this->created; } /** * Set updated * - * @param \DateTime $updated + * @param \DateTimeImmutable $updated * * @return Application */ - public function setUpdated($updated) { + public function setUpdated(\DateTimeImmutable $updated): Application { $this->updated = $updated; return $this; @@ -132,20 +179,20 @@ class Application { /** * Get updated * - * @return \DateTime + * @return \DateTimeImmutable */ - public function getUpdated() { + public function getUpdated(): \DateTimeImmutable { 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; @@ -154,20 +201,20 @@ class Application { /** * 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; @@ -176,9 +223,20 @@ class Application { /** * 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 \DateTimeImmutable('now')); + } + } }