Advertisement
Ananaskirsche

Entity

Sep 21st, 2017
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.88 KB | None | 0 0
  1. <?php
  2. namespace AppBundle\Entity;
  3.  
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Symfony\Component\Security\Core\User\UserInterface;
  6.  
  7. /**
  8.  * @ORM\Table(name="abistuff_users")
  9.  * @ORM\Entity(repositoryClass="AppBundle\Repository\UserRepository")
  10.  */
  11. class User implements UserInterface, \Serializable
  12. {
  13.     /**
  14.      * @ORM\Column(type="integer")
  15.      * @ORM\Id
  16.      * @ORM\GeneratedValue(strategy="AUTO")
  17.      */
  18.     private $id;
  19.  
  20.     /**
  21.      * @ORM\Column(type="string", length=40, unique=true)
  22.      */
  23.     private $username;
  24.  
  25.     /**
  26.      * @ORM\Column(type="string", length=64)
  27.      */
  28.     private $password;
  29.  
  30.     /**
  31.      * @ORM\Column(type="string", length=40, unique=true)
  32.      */
  33.     private $displayname;
  34.  
  35.     /**
  36.      * @ORM\Column(type="boolean", name="is_admin")
  37.      */
  38.     private $isAdmin;
  39.  
  40.     /**
  41.      * @ORM\Column(type="boolean", name="is_active")
  42.      */
  43.     private $isActive;
  44.  
  45.  
  46.     public function __construct()
  47.     {
  48.         $this->isActive = true;
  49.     }
  50.  
  51.  
  52.     public function getSalt()
  53.     {
  54.         //Kann ruhig null sein, da BCRYPT verwendet wird, und der BCRYPT-Algorithmus das selber macht
  55.         return null;
  56.     }
  57.  
  58.  
  59.     public function getRoles()
  60.     {
  61.         return array('ROLE_USER');
  62.     }
  63.  
  64.  
  65.     public function eraseCredentials(){   }
  66.  
  67.  
  68.     public function serialize()
  69.     {
  70.         return serialize(array(
  71.             $this->id, $this->username, $this->password
  72.         ));
  73.     }
  74.  
  75.  
  76.     public function unserialize($serialized)
  77.     {
  78.         list($this->id, $this->username, $this->password) = $this->unserialize($serialized);
  79.     }
  80.  
  81.  
  82.     //<editor-fold desc="Getters und Setters">
  83.     public function getUsername()
  84.     {
  85.         return $this->username;
  86.     }
  87.  
  88.  
  89.     public function getPassword()
  90.     {
  91.         return $this->password;
  92.     }
  93.  
  94.     public function getId()
  95.     {
  96.         return $this->id;
  97.     }
  98.  
  99.     public function getDisplayname()
  100.     {
  101.         return $this->displayname;
  102.     }
  103.  
  104.     public function isActive()
  105.     {
  106.         return $this->isActive;
  107.     }
  108.  
  109.     public function isAdmin()
  110.     {
  111.         return $this->isAdmin;
  112.     }
  113.  
  114.     /**
  115.      * @param mixed $username
  116.      */
  117.     public function setUsername($username)
  118.     {
  119.         $this->username = $username;
  120.     }
  121.  
  122.     /**
  123.      * @param mixed $password
  124.      */
  125.     public function setPassword($password)
  126.     {
  127.         $this->password = $password;
  128.     }
  129.  
  130.     /**
  131.      * @param mixed $displayname
  132.      */
  133.     public function setDisplayname($displayname)
  134.     {
  135.         $this->displayname = $displayname;
  136.     }
  137.  
  138.     /**
  139.      * @param mixed $isAdmin
  140.      */
  141.     public function setIsAdmin($isAdmin)
  142.     {
  143.         $this->isAdmin = $isAdmin;
  144.     }
  145.  
  146.     /**
  147.      * @param mixed $isActive
  148.      */
  149.     public function setIsActive($isActive)
  150.     {
  151.         $this->isActive = $isActive;
  152.     }
  153.     //</editor-fold>
  154. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement