]> Raphaël G. Git Repositories - airbundle/blobdiff - Entity/Application.php
Rename rapsysair:calendar2 command to rapsysair:calendar
[airbundle] / Entity / Application.php
index c157132e5859b46a9ea57f43fb1191a5719b487d..b2672a19aa898ff58a383fed4bb273c27fe7e957 100644 (file)
-<?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
-     */
-    private $id;
-
-    /**
-     * @var \DateTime
-     */
-    private $created;
-
-    /**
-     * @var \DateTime
-     */
-    private $updated;
-
-    /**
-     * @var \Doctrine\Common\Collections\Collection
-     */
-    private $votes;
-
-    /**
-     * @var \Rapsys\AirBundle\Entity\Session
-     */
-    private $session;
-
-    /**
-     * @var \Rapsys\AirBundle\Entity\User
-     */
-    private $user;
-
-    /**
-     * Constructor
-     */
-    public function __construct()
-    {
-        $this->votes = new \Doctrine\Common\Collections\ArrayCollection();
-    }
-
-    /**
-     * Get id
-     *
-     * @return integer
-     */
-    public function getId()
-    {
-        return $this->id;
-    }
-
-    /**
-     * Set created
-     *
-     * @param \DateTime $created
-     *
-     * @return Application
-     */
-    public function setCreated($created)
-    {
-        $this->created = $created;
-
-        return $this;
-    }
-
-    /**
-     * Get created
-     *
-     * @return \DateTime
-     */
-    public function getCreated()
-    {
-        return $this->created;
-    }
-
-    /**
-     * Set updated
-     *
-     * @param \DateTime $updated
-     *
-     * @return Application
-     */
-    public function setUpdated($updated)
-    {
-        $this->updated = $updated;
-
-        return $this;
-    }
-
-    /**
-     * Get updated
-     *
-     * @return \DateTime
-     */
-    public function getUpdated()
-    {
-        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
-     *
-     * @return Application
-     */
-    public function setSession(\Rapsys\AirBundle\Entity\Session $session = null)
-    {
-        $this->session = $session;
-
-        return $this;
-    }
-
-    /**
-     * Get session
-     *
-     * @return \Rapsys\AirBundle\Entity\Session
-     */
-    public function getSession()
-    {
-        return $this->session;
-    }
-
-    /**
-     * Set user
-     *
-     * @param \Rapsys\AirBundle\Entity\User $user
-     *
-     * @return Application
-     */
-    public function setUser(\Rapsys\AirBundle\Entity\User $user = null)
-    {
-        $this->user = $user;
-
-        return $this;
-    }
-
-    /**
-     * Get user
-     *
-     * @return \Rapsys\AirBundle\Entity\User
-     */
-    public function getUser()
-    {
-        return $this->user;
-    }
+class Application {
+       /**
+        * Primary key
+        */
+       private ?int $id = null;
+
+       /**
+        * Dance instance
+        */
+       private Dance $dance;
+
+       /**
+        * Score
+        */
+       private ?float $score = null;
+
+       /**
+        * Cancel datetime
+        */
+       private ?\DateTime $canceled = null;
+
+       /**
+        * Create datetime
+        */
+       private \DateTime $created;
+
+       /**
+        * Update datetime
+        */
+       private \DateTime $updated;
+
+       /**
+        * Session instance
+        */
+       private $session = null;
+
+       /**
+        * User instance
+        */
+       private $user = null;
+
+       /**
+        * Constructor
+        */
+       public function __construct() {
+               //Set defaults
+               $this->created = new \DateTime('now');
+               $this->updated = new \DateTime('now');
+       }
+
+       /**
+        * Get id
+        *
+        * @return integer
+        */
+       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
+        *
+        * @param float $score
+        *
+        * @return Application
+        */
+       public function setScore(?float $score): Application {
+               $this->score = $score;
+
+               return $this;
+       }
+
+       /**
+        * 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
+        */
+       public function getCanceled(): ?\DateTime {
+               return $this->canceled;
+       }
+
+       /**
+        * Set created
+        *
+        * @param \DateTime $created
+        *
+        * @return Application
+        */
+       public function setCreated(\DateTime $created): Application {
+               $this->created = $created;
+
+               return $this;
+       }
+
+       /**
+        * Get created
+        *
+        * @return \DateTime
+        */
+       public function getCreated(): \DateTime {
+               return $this->created;
+       }
+
+       /**
+        * Set updated
+        *
+        * @param \DateTime $updated
+        *
+        * @return Application
+        */
+       public function setUpdated(\DateTime $updated): Application {
+               $this->updated = $updated;
+
+               return $this;
+       }
+
+       /**
+        * Get updated
+        *
+        * @return \DateTime
+        */
+       public function getUpdated(): \DateTime {
+               return $this->updated;
+       }
+
+       /**
+        * Set session
+        *
+        * @param Session $session
+        *
+        * @return Application
+        */
+       public function setSession(Session $session): Application {
+               $this->session = $session;
+
+               return $this;
+       }
+
+       /**
+        * Get session
+        *
+        * @return Session
+        */
+       public function getSession(): Session {
+               return $this->session;
+       }
+
+       /**
+        * Set user
+        *
+        * @param User $user
+        *
+        * @return Application
+        */
+       public function setUser(User $user): Application {
+               $this->user = $user;
+
+               return $this;
+       }
+
+       /**
+        * Get user
+        *
+        * @return User
+        */
+       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'));
+               }
+       }
 }