X-Git-Url: https://git.rapsys.eu/airbundle/blobdiff_plain/af2a5ccc05e664274d24ee8711d398d7dec8808d..44a3b56b054637bc704b7541a4e3d38696b560e4:/Entity/Application.php diff --git a/Entity/Application.php b/Entity/Application.php index a31aa92..48e6992 100644 --- a/Entity/Application.php +++ b/Entity/Application.php @@ -1,7 +1,18 @@ - + * + * 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 */ @@ -12,24 +23,29 @@ class Application { private $id; /** - * @var \DateTime + * @var Dance */ - private $created; + private $dance; /** - * @var \DateTime + * @var float */ - private $updated; - + private $score; - //TODO: ajouter un champ score à replir lors de l'attribution d'une session - //XXX: champ float avec une bonne capacité en décimale + /** + * @var \DateTime + */ + private $canceled; + /** + * @var \DateTime + */ + private $created; /** - * @var \Doctrine\Common\Collections\Collection + * @var \DateTime */ - private $votes; + private $updated; /** * @var \Rapsys\AirBundle\Entity\Session @@ -45,7 +61,8 @@ class Application { * Constructor */ public function __construct() { - $this->votes = new \Doctrine\Common\Collections\ArrayCollection(); + $this->session = null; + $this->user = null; } /** @@ -53,93 +70,128 @@ class Application { * * @return integer */ - public function getId() { + public function getId(): int { return $this->id; } /** - * Set created + * Set dance * - * @param \DateTime $created + * @param Dance $dance + * + * @return Session + */ + public function setDance(Dance $dance): Session { + $this->dance = $dance; + + return $this; + } + + /** + * Get dance + * + * @return Dance + */ + public function getDance(): Dance { + return $this->dance; + } + + /** + * Set score + * + * @param float $score * * @return Application */ - public function setCreated($created) { - $this->created = $created; + public function setScore(?float $score): Application { + $this->score = $score; return $this; } /** - * Get created + * Get score * - * @return \DateTime + * @return float */ - public function getCreated() { - return $this->created; + public function getScore(): ?float { + return $this->score; } /** - * Set updated + * Set canceled * - * @param \DateTime $updated + * @param \DateTime $canceled * * @return Application */ - public function setUpdated($updated) { - $this->updated = $updated; + public function setCanceled(?\DateTime $canceled): Application { + $this->canceled = $canceled; return $this; } /** - * Get updated + * Get canceled * * @return \DateTime */ - public function getUpdated() { - return $this->updated; + public function getCanceled(): ?\DateTime { + return $this->canceled; } /** - * Add vote + * Set created * - * @param \Rapsys\AirBundle\Entity\Vote $vote + * @param \DateTime $created * * @return Application */ - public function addVote(\Rapsys\AirBundle\Entity\Vote $vote) { - $this->votes[] = $vote; + public function setCreated(\DateTime $created): Application { + $this->created = $created; return $this; } /** - * Remove vote + * Get created + * + * @return \DateTime + */ + public function getCreated(): \DateTime { + return $this->created; + } + + /** + * Set updated + * + * @param \DateTime $updated * - * @param \Rapsys\AirBundle\Entity\Vote $vote + * @return Application */ - public function removeVote(\Rapsys\AirBundle\Entity\Vote $vote) { - $this->votes->removeElement($vote); + public function setUpdated(\DateTime $updated): Application { + $this->updated = $updated; + + return $this; } /** - * Get votes + * Get updated * - * @return \Doctrine\Common\Collections\Collection + * @return \DateTime */ - public function getVotes() { - return $this->votes; + 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; @@ -148,20 +200,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; @@ -170,9 +222,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->getEntity()) instanceof Application) { + //Set updated value + $application->setUpdated(new \DateTime('now')); + } + } }