]> Raphaƫl G. Git Repositories - airbundle/blobdiff - Entity/Snippet.php
Add snippet hat field
[airbundle] / Entity / Snippet.php
index 20a19401ffc2549f396be30f50e11fb54c483631..999091f6733d220b9f92c72cbf83cf405cdde7c2 100644 (file)
@@ -29,6 +29,21 @@ class Snippet {
         */
        protected $class;
 
+       /**
+        * @var string
+        */
+       protected $short;
+
+       /**
+        * @var integer
+        */
+       protected $rate;
+
+       /**
+        * @var bool
+        */
+       protected $hat;
+
        /**
         * @var string
         */
@@ -69,6 +84,13 @@ class Snippet {
         */
        protected $user;
 
+       /**
+        * Constructor
+        */
+       public function __construct() {
+               $this->hat = true;
+       }
+
        /**
         * Get id
         *
@@ -144,6 +166,71 @@ class Snippet {
                return $this->class;
        }
 
+       /**
+        * Set short
+        *
+        * @param string $short
+        *
+        * @return Snippet
+        */
+       public function setShort($short) {
+               $this->short = $short;
+
+               return $this;
+       }
+
+       /**
+        * Get short
+        *
+        * @return string
+        */
+       public function getShort() {
+               return $this->short;
+       }
+
+       /**
+        * Set rate
+        *
+        * @param string $rate
+        *
+        * @return Snippet
+        */
+       public function setRate($rate) {
+               $this->rate = $rate;
+
+               return $this;
+       }
+
+       /**
+        * Get rate
+        *
+        * @return string
+        */
+       public function getRate() {
+               return $this->rate;
+       }
+
+       /**
+        * Set hat
+        *
+        * @param bool $hat
+        *
+        * @return User
+        */
+       public function setHat(bool $hat) {
+               $this->hat = $hat;
+
+               return $this;
+       }
+
+       /**
+        * Get hat
+        *
+        * @return bool
+        */
+       public function getHat(): bool {
+               return $this->hat;
+       }
        /**
         * Set contact
         *
@@ -319,4 +406,15 @@ class Snippet {
        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'));
+               }
+       }
 }