]> Raphaël G. Git Repositories - airbundle/blobdiff - Entity/Snippet.php
Remove short title
[airbundle] / Entity / Snippet.php
index 20a19401ffc2549f396be30f50e11fb54c483631..4e9d406c2b10572a3e48a29c6e59a0cc1d6a4c5f 100644 (file)
@@ -1,9 +1,17 @@
-<?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 Rapsys\AirBundle\Entity\Location;
-use Rapsys\AirBundle\Entity\User;
+use Doctrine\ORM\Event\PreUpdateEventArgs;
 
 /**
  * Snippet
 
 /**
  * Snippet
@@ -29,6 +37,21 @@ class Snippet {
         */
        protected $class;
 
         */
        protected $class;
 
+       /**
+        * @var string
+        */
+       protected $short;
+
+       /**
+        * @var integer
+        */
+       protected $rate;
+
+       /**
+        * @var bool
+        */
+       protected $hat;
+
        /**
         * @var string
         */
        /**
         * @var string
         */
@@ -60,21 +83,36 @@ class Snippet {
        protected $updated;
 
        /**
        protected $updated;
 
        /**
-        * @var \Rapsys\UserBundle\Entity\Location
+        * @var Location
         */
        protected $location;
 
        /**
         */
        protected $location;
 
        /**
-        * @var \Rapsys\UserBundle\Entity\User
+        * @var User
         */
        protected $user;
 
         */
        protected $user;
 
+       /**
+        * Constructor
+        */
+       public function __construct() {
+               $this->description = null;
+               $this->class = null;
+               $this->short = null;
+               $this->rate = null;
+               $this->hat = null;
+               $this->contact = null;
+               $this->donate = null;
+               $this->link = null;
+               $this->profile = null;
+       }
+
        /**
         * Get id
         *
         * @return integer
         */
        /**
         * Get id
         *
         * @return integer
         */
-       public function getId() {
+       public function getId(): int {
                return $this->id;
        }
 
                return $this->id;
        }
 
@@ -85,7 +123,7 @@ class Snippet {
         *
         * @return Snippet
         */
         *
         * @return Snippet
         */
-       public function setLocale($locale) {
+       public function setLocale(string $locale): Snippet {
                $this->locale = $locale;
 
                return $this;
                $this->locale = $locale;
 
                return $this;
@@ -96,7 +134,7 @@ class Snippet {
         *
         * @return string
         */
         *
         * @return string
         */
-       public function getLocale() {
+       public function getLocale(): string {
                return $this->locale;
        }
 
                return $this->locale;
        }
 
@@ -107,7 +145,7 @@ class Snippet {
         *
         * @return Snippet
         */
         *
         * @return Snippet
         */
-       public function setDescription($description) {
+       public function setDescription(?string $description): Snippet {
                $this->description = $description;
 
                return $this;
                $this->description = $description;
 
                return $this;
@@ -118,7 +156,7 @@ class Snippet {
         *
         * @return string
         */
         *
         * @return string
         */
-       public function getDescription() {
+       public function getDescription(): ?string {
                return $this->description;
        }
 
                return $this->description;
        }
 
@@ -129,7 +167,7 @@ class Snippet {
         *
         * @return Snippet
         */
         *
         * @return Snippet
         */
-       public function setClass($class) {
+       public function setClass(?string $class): Snippet {
                $this->class = $class;
 
                return $this;
                $this->class = $class;
 
                return $this;
@@ -140,10 +178,75 @@ class Snippet {
         *
         * @return string
         */
         *
         * @return string
         */
-       public function getClass() {
+       public function getClass(): ?string {
                return $this->class;
        }
 
                return $this->class;
        }
 
+       /**
+        * Set short
+        *
+        * @param string $short
+        *
+        * @return Snippet
+        */
+       public function setShort(?string $short): Snippet {
+               $this->short = $short;
+
+               return $this;
+       }
+
+       /**
+        * Get short
+        *
+        * @return string
+        */
+       public function getShort(): ?string {
+               return $this->short;
+       }
+
+       /**
+        * Set rate
+        *
+        * @param int $rate
+        *
+        * @return Snippet
+        */
+       public function setRate(?int $rate): Snippet {
+               $this->rate = $rate;
+
+               return $this;
+       }
+
+       /**
+        * Get rate
+        *
+        * @return int
+        */
+       public function getRate(): ?int {
+               return $this->rate;
+       }
+
+       /**
+        * Set hat
+        *
+        * @param bool $hat
+        *
+        * @return User
+        */
+       public function setHat(?bool $hat): Snippet {
+               $this->hat = $hat;
+
+               return $this;
+       }
+
+       /**
+        * Get hat
+        *
+        * @return bool
+        */
+       public function getHat(): ?bool {
+               return $this->hat;
+       }
        /**
         * Set contact
         *
        /**
         * Set contact
         *
@@ -151,7 +254,7 @@ class Snippet {
         *
         * @return Snippet
         */
         *
         * @return Snippet
         */
-       public function setContact($contact) {
+       public function setContact(?string $contact): Snippet {
                $this->contact = $contact;
 
                return $this;
                $this->contact = $contact;
 
                return $this;
@@ -162,7 +265,7 @@ class Snippet {
         *
         * @return string
         */
         *
         * @return string
         */
-       public function getContact() {
+       public function getContact(): ?string {
                return $this->contact;
        }
 
                return $this->contact;
        }
 
@@ -173,7 +276,7 @@ class Snippet {
         *
         * @return Snippet
         */
         *
         * @return Snippet
         */
-       public function setDonate($donate) {
+       public function setDonate(?string $donate): Snippet {
                $this->donate = $donate;
 
                return $this;
                $this->donate = $donate;
 
                return $this;
@@ -184,7 +287,7 @@ class Snippet {
         *
         * @return string
         */
         *
         * @return string
         */
-       public function getDonate() {
+       public function getDonate(): ?string {
                return $this->donate;
        }
 
                return $this->donate;
        }
 
@@ -195,7 +298,7 @@ class Snippet {
         *
         * @return Snippet
         */
         *
         * @return Snippet
         */
-       public function setLink($link) {
+       public function setLink(?string $link): Snippet {
                $this->link = $link;
 
                return $this;
                $this->link = $link;
 
                return $this;
@@ -206,7 +309,7 @@ class Snippet {
         *
         * @return string
         */
         *
         * @return string
         */
-       public function getLink() {
+       public function getLink(): ?string {
                return $this->link;
        }
 
                return $this->link;
        }
 
@@ -217,7 +320,7 @@ class Snippet {
         *
         * @return Snippet
         */
         *
         * @return Snippet
         */
-       public function setProfile($profile) {
+       public function setProfile(?string $profile): Snippet {
                $this->profile = $profile;
 
                return $this;
                $this->profile = $profile;
 
                return $this;
@@ -228,7 +331,7 @@ class Snippet {
         *
         * @return string
         */
         *
         * @return string
         */
-       public function getProfile() {
+       public function getProfile(): ?string {
                return $this->profile;
        }
 
                return $this->profile;
        }
 
@@ -239,7 +342,7 @@ class Snippet {
         *
         * @return Snippet
         */
         *
         * @return Snippet
         */
-       public function setCreated($created) {
+       public function setCreated(\DateTime $created): Snippet {
                $this->created = $created;
 
                return $this;
                $this->created = $created;
 
                return $this;
@@ -250,7 +353,7 @@ class Snippet {
         *
         * @return \DateTime
         */
         *
         * @return \DateTime
         */
-       public function getCreated() {
+       public function getCreated(): \DateTime {
                return $this->created;
        }
 
                return $this->created;
        }
 
@@ -261,7 +364,7 @@ class Snippet {
         *
         * @return Snippet
         */
         *
         * @return Snippet
         */
-       public function setUpdated($updated) {
+       public function setUpdated(\DateTime $updated): Snippet {
                $this->updated = $updated;
 
                return $this;
                $this->updated = $updated;
 
                return $this;
@@ -272,7 +375,7 @@ class Snippet {
         *
         * @return \DateTime
         */
         *
         * @return \DateTime
         */
-       public function getUpdated() {
+       public function getUpdated(): \DateTime {
                return $this->updated;
        }
 
                return $this->updated;
        }
 
@@ -319,4 +422,15 @@ class Snippet {
        public function getUser() {
                return $this->user;
        }
        public function getUser() {
                return $this->user;
        }
+
+       /**
+        * {@inheritdoc}
+        */
+       public function preUpdate(\Doctrine\ORM\Event\PreUpdateEventArgs  $eventArgs) {
+               //Check that we have an snippet instance
+               if (($snippet = $eventArgs->getEntity()) instanceof Snippet) {
+                       //Set updated value
+                       $snippet->setUpdated(new \DateTime('now'));
+               }
+       }
 }
 }