Advertisement
Guest User

Untitled

a guest
Sep 12th, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.93 KB | None | 0 0
  1. <?php
  2.  
  3. // src/AppBundle/Entity/User.php
  4. namespace AndroneBundle\Entity;
  5.  
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Security\Core\User\UserInterface;
  8.  
  9. /**
  10.  * @ORM\Entity
  11.  * @ORM\Table(name="users")
  12.  */
  13. class User implements UserInterface, \Serializable
  14. {
  15.     /**
  16.      * @ORM\Column(type="integer")
  17.      * @ORM\Id
  18.      * @ORM\GeneratedValue(strategy="AUTO")
  19.      */
  20.     private $id;
  21.  
  22.     /**
  23.      * @ORM\Column(type="string", length=25, unique=true)
  24.      */
  25.     private $username;
  26.  
  27.     /**
  28.      * @ORM\Column(type="string", length=64)
  29.      */
  30.     private $password;
  31.  
  32.     /**
  33.      * @ORM\Column(name="is_active", type="boolean")
  34.      */
  35.     private $isActive;
  36.  
  37.     /**
  38.      * @ORM\Column(name="android_version", type="integer")
  39.      */
  40.     private $androidVersion;
  41.  
  42.     /**
  43.      * @ORM\Column(type="string", columnDefinition="ENUM('ROLE_ADMIN', 'ROLE_USER', 'ROLE_SUPER')")
  44.      */
  45.     private $role;
  46.  
  47.     public function __construct()
  48.     {
  49.         $this->isActive = true;
  50.         // may not be needed, see section on salt below
  51.         // $this->salt = md5(uniqid(null, true));
  52.     }
  53.  
  54.     public function getUsername()
  55.     {
  56.         return $this->username;
  57.     }
  58.  
  59.     public function getSalt()
  60.     {
  61.         // you *may* need a real salt depending on your encoder
  62.         // see section on salt below
  63.         return null;
  64.     }
  65.  
  66.     public function getPassword()
  67.     {
  68.         return $this->password;
  69.     }
  70.  
  71.     public function getRoles()
  72.     {
  73.         return array('ROLE_USER');
  74.     }
  75.  
  76.     public function eraseCredentials()
  77.     {
  78.     }
  79.  
  80.     /** @see \Serializable::serialize() */
  81.     public function serialize()
  82.     {
  83.         return serialize(array(
  84.             $this->id,
  85.             $this->username,
  86.             $this->password,
  87.             // see section on salt below
  88.             // $this->salt,
  89.         ));
  90.     }
  91.  
  92.     /** @see \Serializable::unserialize() */
  93.     public function unserialize($serialized)
  94.     {
  95.         list (
  96.             $this->id,
  97.             $this->username,
  98.             $this->password,
  99.             // see section on salt below
  100.             // $this->salt
  101.             ) = unserialize($serialized);
  102.     }
  103.  
  104.     /**
  105.      * Get id
  106.      *
  107.      * @return integer
  108.      */
  109.     public function getId()
  110.     {
  111.         return $this->id;
  112.     }
  113.  
  114.     /**
  115.      * Set username
  116.      *
  117.      * @param string $username
  118.      *
  119.      * @return User
  120.      */
  121.     public function setUsername($username)
  122.     {
  123.         $this->username = $username;
  124.  
  125.         return $this;
  126.     }
  127.  
  128.     /**
  129.      * Set password
  130.      *
  131.      * @param string $password
  132.      *
  133.      * @return User
  134.      */
  135.     public function setPassword($password)
  136.     {
  137.         $this->password = $password;
  138.  
  139.         return $this;
  140.     }
  141.  
  142.     /**
  143.      * Set isActive
  144.      *
  145.      * @param boolean $isActive
  146.      *
  147.      * @return User
  148.      */
  149.     public function setIsActive($isActive)
  150.     {
  151.         $this->isActive = $isActive;
  152.  
  153.         return $this;
  154.     }
  155.  
  156.     /**
  157.      * Get isActive
  158.      *
  159.      * @return boolean
  160.      */
  161.     public function getIsActive()
  162.     {
  163.         return $this->isActive;
  164.     }
  165.  
  166.     /**
  167.      * Set androidVersion
  168.      *
  169.      * @param integer $androidVersion
  170.      *
  171.      * @return User
  172.      */
  173.     public function setAndroidVersion($androidVersion)
  174.     {
  175.         $this->androidVersion = $androidVersion;
  176.  
  177.         return $this;
  178.     }
  179.  
  180.     /**
  181.      * Get androidVersion
  182.      *
  183.      * @return integer
  184.      */
  185.     public function getAndroidVersion()
  186.     {
  187.         return $this->androidVersion;
  188.     }
  189.  
  190.     /**
  191.      * Set role
  192.      *
  193.      * @param string $role
  194.      *
  195.      * @return User
  196.      */
  197.     public function setRole($role)
  198.     {
  199.         $this->role = $role;
  200.  
  201.         return $this;
  202.     }
  203.  
  204.     /**
  205.      * Get role
  206.      *
  207.      * @return string
  208.      */
  209.     public function getRole()
  210.     {
  211.         return $this->role;
  212.     }
  213. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement