Advertisement
Guest User

Untitled

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