X-Git-Url: https://git.rapsys.eu/airbundle/blobdiff_plain/68663463f2ad060a95d809454e8f035dc0496cf5..010e38c2810846d5812a0ec91df98cddfdef8de4:/Entity/Application.php diff --git a/Entity/Application.php b/Entity/Application.php index 2e8cca5..b54b1e2 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 */ @@ -31,11 +42,6 @@ class Application { */ private $updated; - /** - * @var \Doctrine\Common\Collections\Collection - */ - private $votes; - /** * @var \Rapsys\AirBundle\Entity\Session */ @@ -50,7 +56,8 @@ class Application { * Constructor */ public function __construct() { - $this->votes = new \Doctrine\Common\Collections\ArrayCollection(); + $this->session = null; + $this->user = null; } /** @@ -58,7 +65,7 @@ class Application { * * @return integer */ - public function getId() { + public function getId(): int { return $this->id; } @@ -69,7 +76,7 @@ class Application { * * @return Application */ - public function setScore($score) { + public function setScore(?float $score): Application { $this->score = $score; return $this; @@ -80,7 +87,7 @@ class Application { * * @return float */ - public function getScore() { + public function getScore(): ?float { return $this->score; } @@ -91,7 +98,7 @@ class Application { * * @return Application */ - public function setCanceled($canceled) { + public function setCanceled(?\DateTime $canceled): Application { $this->canceled = $canceled; return $this; @@ -102,7 +109,7 @@ class Application { * * @return \DateTime */ - public function getCanceled() { + public function getCanceled(): ?\DateTime { return $this->canceled; } @@ -113,7 +120,7 @@ class Application { * * @return Application */ - public function setCreated($created) { + public function setCreated(\DateTime $created): Application { $this->created = $created; return $this; @@ -124,7 +131,7 @@ class Application { * * @return \DateTime */ - public function getCreated() { + public function getCreated(): \DateTime { return $this->created; } @@ -135,7 +142,7 @@ class Application { * * @return Application */ - public function setUpdated($updated) { + public function setUpdated(\DateTime $updated): Application { $this->updated = $updated; return $this; @@ -146,49 +153,18 @@ class Application { * * @return \DateTime */ - public function getUpdated() { + public function getUpdated(): \DateTime { return $this->updated; } - /** - * Add vote - * - * @param \Rapsys\AirBundle\Entity\Vote $vote - * - * @return Application - */ - public function addVote(\Rapsys\AirBundle\Entity\Vote $vote) { - $this->votes[] = $vote; - - return $this; - } - - /** - * Remove vote - * - * @param \Rapsys\AirBundle\Entity\Vote $vote - */ - public function removeVote(\Rapsys\AirBundle\Entity\Vote $vote) { - $this->votes->removeElement($vote); - } - - /** - * Get votes - * - * @return \Doctrine\Common\Collections\Collection - */ - public function getVotes() { - return $this->votes; - } - /** * 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; @@ -197,20 +173,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; @@ -219,9 +195,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 (($user = $eventArgs->getEntity()) instanceof Application) { + //Set updated value + $user->setUpdated(new \DateTime('now')); + } + } }