Advertisement
Guest User

User

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