Advertisement
Guest User

Untitled

a guest
Jul 5th, 2011
761
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.88 KB | None | 0 0
  1. <?php
  2.  
  3. namespace F3\FFGBundle\Entity;
  4.  
  5. use Symfony\Component\Security\Core\User\UserInterface;
  6. use Doctrine\ORM\Mapping as ORM;
  7.  
  8. /**
  9.  * F3\FFGBundle\Entity\User
  10.  *
  11.  * @ORM\Table()
  12.  * @ORM\Entity
  13.  */
  14. class User implements UserInterface
  15. {
  16.     /**
  17.      * @var integer $id
  18.      *
  19.      * @ORM\Column(name="id", type="integer")
  20.      * @ORM\Id
  21.      * @ORM\GeneratedValue(strategy="AUTO")
  22.      */
  23.     private $id;
  24.  
  25.     /**
  26.      * @var string $username
  27.      *
  28.      * @ORM\Column(name="username", type="string", length=255)
  29.      */
  30.     private $username;
  31.  
  32.     /**
  33.      * @var string $password
  34.      *
  35.      * @ORM\Column(name="password", type="string", length=40)
  36.      */
  37.     private $password;
  38.  
  39.  
  40.     /**
  41.      * Get id
  42.      *
  43.      * @return integer
  44.      */
  45.     public function getId()
  46.     {
  47.         return $this->id;
  48.     }
  49.  
  50.     /**
  51.      * Set username
  52.      *
  53.      * @param string $username
  54.      */
  55.     public function setUsername($username)
  56.     {
  57.         $this->username = $username;
  58.     }
  59.  
  60.     /**
  61.      * Get username
  62.      *
  63.      * @return string
  64.      */
  65.     public function getUsername()
  66.     {
  67.         return $this->username;
  68.     }
  69.  
  70.     /**
  71.      * Set password
  72.      *
  73.      * @param string $password
  74.      */
  75.     public function setPassword($password)
  76.     {
  77.         $this->password = $password;
  78.     }
  79.  
  80.     /**
  81.      * Get password
  82.      *
  83.      * @return string
  84.      */
  85.     public function getPassword()
  86.     {
  87.         return $this->password;
  88.     }
  89.    
  90.    
  91.    
  92.     /********* CODE BELOW IS TO MAKE IT WORK AS AUTH CLASS **********/
  93.    
  94.    
  95.    
  96.     public function getRoles()
  97.     {
  98.         return array();
  99.     }
  100.    
  101.     public function getSalt()
  102.     {
  103.         return null;
  104.     }
  105.    
  106.     public function eraseCredentials() {}
  107.    
  108.     public function equals(UserInterface $user)
  109.     {
  110.         if (!$user instanceof User) {
  111.             return false;
  112.         }
  113.  
  114.         if ($this->password !== $user->getPassword()) {
  115.             return false;
  116.         }
  117.  
  118.         if ($this->getSalt() !== $user->getSalt()) {
  119.             return false;
  120.         }
  121.  
  122.         if ($this->username !== $user->getUsername()) {
  123.             return false;
  124.         }
  125.        
  126.         return true;
  127.     }
  128. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement