]> Raphaƫl G. Git Repositories - userbundle/blobdiff - Entity/User.php
Set mail, password as optional field
[userbundle] / Entity / User.php
index 6d10f33dd9be026fdc5f41eb4e4321db8e3389d2..8fb41053a352ab4de738eb8351e2aec9d23dde4b 100644 (file)
@@ -271,7 +271,7 @@ class User implements UserInterface, \Serializable {
        /**
         * Get civility
         */
-       public function getCivility(): Civility {
+       public function getCivility(): ?Civility {
                return $this->civility;
        }
 
@@ -400,6 +400,17 @@ class User implements UserInterface, \Serializable {
                return $this->active;
        }
 
+       /**
+        * {@inheritdoc}
+        */
+       public function preUpdate(\Doctrine\ORM\Event\PreUpdateEventArgs $eventArgs) {
+               //Check that we have an user instance
+               if (($user = $eventArgs->getEntity()) instanceof User) {
+                       //Set updated value
+                       $user->setUpdated(new \DateTime('now'));
+               }
+       }
+
        /**
         * Returns a string representation of the user
         *