Guest User

Untitled

a guest
Jan 30th, 2013
66
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. namespace MyApp\UserBundle\Entity;
  4.  
  5. use FOS\UserBundle\Entity\User as BaseUser;
  6. use Doctrine\ORM\Mapping as ORM;
  7.  
  8. class User extends BaseUser
  9. {
  10. /**
  11. * @ORM\Id
  12. * @ORM\Column(type="integer")
  13. * @ORM\GeneratedValue(strategy="AUTO")
  14. */
  15. protected $id;
  16.  
  17. /**
  18. * @var string
  19. *
  20. * @ORM\Column(name="firstname", type="string", length=255)
  21. */
  22. protected $firstname;
  23.  
  24. /**
  25. * @var string
  26. *
  27. * @ORM\Column(name="lastname", type="string", length=255)
  28. */
  29. protected $lastname;
  30.  
  31. /**
  32. * @var string
  33. *
  34. * @ORM\Column(name="facebookId", type="string", length=255)
  35. */
  36. protected $facebookId;
  37.  
  38. /**
  39. * @return int
  40. */
  41. public function getId()
  42. {
  43. return $this->id;
  44. }
  45.  
  46. /**
  47. * @return string
  48. */
  49. public function getFirstname()
  50. {
  51. return $this->firstname;
  52. }
  53.  
  54. /**
  55. * @param string $firstname
  56. */
  57. public function setFirstname($firstname)
  58. {
  59. $this->firstname = $firstname;
  60. }
  61.  
  62. /**
  63. * @return string
  64. */
  65. public function getLastname()
  66. {
  67. return $this->lastname;
  68. }
  69.  
  70. /**
  71. * @param string $lastname
  72. */
  73. public function setLastname($lastname)
  74. {
  75. $this->lastname = $lastname;
  76. }
  77.  
  78. /**
  79. * Get the full name of the user (first + last name)
  80. * @return string
  81. */
  82. public function getFullName()
  83. {
  84. return $this->getFirstName() . ' ' . $this->getLastname();
  85. }
  86.  
  87. /**
  88. * @param string $facebookId
  89. * @return void
  90. */
  91. public function setFacebookId($facebookId)
  92. {
  93. $this->facebookId = $facebookId;
  94. $this->setUsername($facebookId);
  95. $this->salt = '';
  96. }
  97.  
  98. /**
  99. * @return string
  100. */
  101. public function getFacebookId()
  102. {
  103. return $this->facebookId;
  104. }
  105.  
  106. /**
  107. * @param Array
  108. */
  109. public function setFBData($fbdata)
  110. {
  111. if (isset($fbdata['id'])) {
  112. $this->setFacebookId($fbdata['id']);
  113. $this->addRole('ROLE_FACEBOOK');
  114. }
  115. if (isset($fbdata['first_name'])) {
  116. $this->setFirstname($fbdata['first_name']);
  117. }
  118. if (isset($fbdata['last_name'])) {
  119. $this->setLastname($fbdata['last_name']);
  120. }
  121. if (isset($fbdata['email'])) {
  122. $this->setEmail($fbdata['email']);
  123. }
  124. }
  125.  
  126. }
RAW Paste Data