]> Raphaël G. Git Repositories - airbundle/blobdiff - Entity/Application.php
Add todo about shared fields to drop
[airbundle] / Entity / Application.php
index c9229328a4d214159a13564c2580d25a279996e3..5d3120360342c6761cf51c76bca43fe7e2df1a60 100644 (file)
@@ -1,7 +1,18 @@
-<?php
+<?php declare(strict_types=1);
+
+/*
+ * this file is part of the rapsys packbundle 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;
 
 
 namespace Rapsys\AirBundle\Entity;
 
+use Doctrine\ORM\Event\PreUpdateEventArgs;
+
 /**
  * Application
  */
 /**
  * Application
  */
@@ -11,20 +22,30 @@ class Application {
         */
        private $id;
 
         */
        private $id;
 
+       /**
+        * @var Dance
+        */
+       private $dance;
+
+       /**
+        * @var float
+        */
+       private $score;
+
        /**
         * @var \DateTime
         */
        /**
         * @var \DateTime
         */
-       private $created;
+       private $canceled;
 
        /**
         * @var \DateTime
         */
 
        /**
         * @var \DateTime
         */
-       private $updated;
+       private $created;
 
        /**
 
        /**
-        * @var \Doctrine\Common\Collections\Collection
+        * @var \DateTime
         */
         */
-       private $votes;
+       private $updated;
 
        /**
         * @var \Rapsys\AirBundle\Entity\Session
 
        /**
         * @var \Rapsys\AirBundle\Entity\Session
@@ -40,7 +61,13 @@ class Application {
         * Constructor
         */
        public function __construct() {
         * Constructor
         */
        public function __construct() {
-               $this->votes = new \Doctrine\Common\Collections\ArrayCollection();
+               //Set defaults
+               $this->score = null;
+               $this->canceled = null;
+               $this->created = new \DateTime('now');
+               $this->updated = new \DateTime('now');
+               $this->session = null;
+               $this->user = null;
        }
 
        /**
        }
 
        /**
@@ -48,93 +75,128 @@ class Application {
         *
         * @return integer
         */
         *
         * @return integer
         */
-       public function getId() {
+       public function getId(): int {
                return $this->id;
        }
 
        /**
                return $this->id;
        }
 
        /**
-        * Set created
+        * Set dance
         *
         *
-        * @param \DateTime $created
+        * @param Dance $dance
         *
         * @return Application
         */
         *
         * @return Application
         */
-       public function setCreated($created) {
-               $this->created = $created;
+       public function setDance(Dance $dance): Application {
+               $this->dance = $dance;
 
                return $this;
        }
 
        /**
 
                return $this;
        }
 
        /**
-        * Get created
+        * Get dance
         *
         *
-        * @return \DateTime
+        * @return Dance
         */
         */
-       public function getCreated() {
-               return $this->created;
+       public function getDance(): Dance {
+               return $this->dance;
        }
 
        /**
        }
 
        /**
-        * Set updated
+        * Set score
         *
         *
-        * @param \DateTime $updated
+        * @param float $score
         *
         * @return Application
         */
         *
         * @return Application
         */
-       public function setUpdated($updated) {
-               $this->updated = $updated;
+       public function setScore(?float $score): Application {
+               $this->score = $score;
 
                return $this;
        }
 
        /**
 
                return $this;
        }
 
        /**
-        * Get updated
+        * Get score
+        *
+        * @return float
+        */
+       public function getScore(): ?float {
+               return $this->score;
+       }
+
+       /**
+        * Set canceled
+        *
+        * @param \DateTime $canceled
+        *
+        * @return Application
+        */
+       public function setCanceled(?\DateTime $canceled): Application {
+               $this->canceled = $canceled;
+
+               return $this;
+       }
+
+       /**
+        * Get canceled
         *
         * @return \DateTime
         */
         *
         * @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
         */
         *
         * @return Application
         */
-       public function addVote(\Rapsys\AirBundle\Entity\Vote $vote) {
-               $this->votes[] = $vote;
+       public function setCreated(\DateTime $created): Application {
+               $this->created = $created;
 
                return $this;
        }
 
        /**
 
                return $this;
        }
 
        /**
-        * Remove vote
+        * Get created
         *
         *
-        * @param \Rapsys\AirBundle\Entity\Vote $vote
+        * @return \DateTime
         */
         */
-       public function removeVote(\Rapsys\AirBundle\Entity\Vote $vote) {
-               $this->votes->removeElement($vote);
+       public function getCreated(): \DateTime {
+               return $this->created;
        }
 
        /**
        }
 
        /**
-        * Get votes
+        * Set updated
+        *
+        * @param \DateTime $updated
         *
         *
-        * @return \Doctrine\Common\Collections\Collection
+        * @return Application
         */
         */
-       public function getVotes() {
-               return $this->votes;
+       public function setUpdated(\DateTime $updated): Application {
+               $this->updated = $updated;
+
+               return $this;
+       }
+
+       /**
+        * Get updated
+        *
+        * @return \DateTime
+        */
+       public function getUpdated(): \DateTime {
+               return $this->updated;
        }
 
        /**
         * Set session
         *
        }
 
        /**
         * Set session
         *
-        * @param \Rapsys\AirBundle\Entity\Session $session
+        * @param Session $session
         *
         * @return Application
         */
         *
         * @return Application
         */
-       public function setSession(\Rapsys\AirBundle\Entity\Session $session = null) {
+       public function setSession(Session $session): Application {
                $this->session = $session;
 
                return $this;
                $this->session = $session;
 
                return $this;
@@ -143,20 +205,20 @@ class Application {
        /**
         * Get session
         *
        /**
         * Get session
         *
-        * @return \Rapsys\AirBundle\Entity\Session
+        * @return Session
         */
         */
-       public function getSession() {
+       public function getSession(): Session {
                return $this->session;
        }
 
        /**
         * Set user
         *
                return $this->session;
        }
 
        /**
         * Set user
         *
-        * @param \Rapsys\AirBundle\Entity\User $user
+        * @param User $user
         *
         * @return Application
         */
         *
         * @return Application
         */
-       public function setUser(\Rapsys\AirBundle\Entity\User $user = null) {
+       public function setUser(User $user): Application {
                $this->user = $user;
 
                return $this;
                $this->user = $user;
 
                return $this;
@@ -165,9 +227,20 @@ class Application {
        /**
         * Get user
         *
        /**
         * Get user
         *
-        * @return \Rapsys\AirBundle\Entity\User
+        * @return User
         */
         */
-       public function getUser() {
+       public function getUser(): User {
                return $this->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'));
+               }
+       }
 }
 }