Guest User

Untitled

a guest
Sep 18th, 2018
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.55 KB | None | 0 0
  1. /**
  2. * Personnel
  3. * @ORMTable(name="Personnel")
  4. * @ORMEntity
  5. */
  6.  
  7. class Personnel extends BaseUser implements SamlUserInterface
  8. {
  9. /**
  10. * @var integer
  11. *
  12. * @ORMColumn(name="id", type="bigint", nullable=false)
  13. * @ORMId
  14. * @ORMGeneratedValue(strategy="CUSTOM")
  15. * @ORMCustomIdGenerator(class="PDFGrandParcBundleDoctrineGuidGeneratorPersonnel")
  16. */
  17. protected $id;
  18.  
  19. /**
  20. * @var string
  21. *
  22. * @ORMColumn(name="Pe_nom", type="string", length=50, nullable=false)
  23. */
  24. private $peNom;
  25.  
  26. /**
  27. * @var string
  28. *
  29. * @ORMColumn(name="Pe_nomusuel", type="string", length=100, nullable=false)
  30. */
  31. private $peNomusuel;
  32.  
  33. /**
  34. * @var Droit
  35. *
  36. * @ORMManyToMany(targetEntity="PDFGrandParcBundleEntityDroit")
  37. * @ORMJoinTable(name="PersonnelToDroit",
  38. * joinColumns={
  39. * @ORMJoinColumn(name="fk_personnel", referencedColumnName="id")
  40. * },
  41. * inverseJoinColumns={
  42. * @ORMJoinColumn(name="fk_droit", referencedColumnName="Dr_id")
  43. * }
  44. * )
  45. */
  46. private $droits;
  47.  
  48. /**
  49. * @var Service
  50. *
  51. * @ORMManyToMany(targetEntity="PDFGrandParcBundleEntityService")
  52. * @ORMJoinTable(name="PersonnelToService",
  53. * joinColumns={
  54. * @ORMJoinColumn(name="fk_personnel", referencedColumnName="id")
  55. * },
  56. * inverseJoinColumns={
  57. * @ORMJoinColumn(name="fk_service", referencedColumnName="Se_id")
  58. * }
  59. * )
  60. */
  61. private $services;
  62.  
  63. public function __construct()
  64. {
  65. $this->droits = new ArrayCollection();
  66. $this->services = new ArrayCollection();
  67. }
  68.  
  69. public function setSamlAttributes(array $attributes){
  70. $this->peEmail = $attributes['mail'][0];
  71. $this->peNom = $attributes['sn'][0];
  72. $this->setPeNomusuel($attributes['cn'][0]);
  73. $this->setRoles($attributes['memberOf']);
  74.  
  75. $this->setEmail($attributes['mail'][0]);
  76. $this->setUsername($attributes['sAMAccountName'][0]);
  77. parent::setUsername($attributes['sAMAccountName'][0]);
  78. }
  79.  
  80. function getId() {
  81. return $this->id;
  82. }
  83.  
  84. function getPeNom() {
  85. return $this->peNom;
  86. }
  87.  
  88. function getPeNomusuel(){
  89. return $this->peNomusuel;
  90. }
  91.  
  92. function getPeEmail() {
  93. return $this->peEmail;
  94. }
  95.  
  96. function getDroits() {
  97. return $this->droits;
  98. }
  99.  
  100. function getServices() {
  101. return $this->services;
  102. }
  103.  
  104. public function setRoles($roles)
  105. {
  106. $all = [];
  107. /*on recupere tous les roles*/
  108. for ($i=0; $i < sizeof($roles); $i++) {
  109. $all = array_merge($all,explode(',',$roles[$i]));
  110. }
  111. $all = array_unique($all);
  112. $all2=[];
  113. foreach ($all as $oneRole) {
  114. $all2[] = 'ROLE_'.$oneRole;
  115. }
  116. $this->roles = $all2;
  117. }
  118.  
  119. public function getRoles(){
  120. return $this->roles;
  121. }
  122.  
  123. public function getPassword(){
  124. return 'null';
  125. }
  126.  
  127. public function getSalt(){
  128. }
  129.  
  130. public function getUsername(){
  131. return parent::getUsername();
  132. }
  133. public function eraseCredentials(){
  134. }
  135. public function setId($id)
  136. {
  137. $this->id = $id;
  138. return $this;
  139. }
  140. public function setPeNom($peNom)
  141. {
  142. $this->peNom = $peNom;
  143. return $this;
  144. }
  145. public function setPeEmail($peEmail)
  146. {
  147. $this->peEmail = $peEmail;
  148. return $this;
  149. }
  150.  
  151. public function setPassword($pePassword)
  152. {
  153. $this->pePassword = $pePassword;
  154. return $this;
  155. }
  156. public function setDroits($droits)
  157. {
  158. $this->droits = $droits;
  159. return $this;
  160. }
  161. public function setServices($services)
  162. {
  163. $this->services = $services;
  164. return $this;
  165. }
  166.  
  167. Personnel {
  168. id: "1826142386850000097"
  169. -peNom: null
  170. -peNomusuel: null
  171. -droits: null
  172. -services: null
  173. username: "user"
  174. usernameCanonical: "user"
  175. email: "user@email.com"
  176. emailCanonical: "user@email.com"
  177. enabled: null
  178. salt: null
  179. password: null
  180. plainPassword: null
  181. lastLogin: null
  182. confirmationToken: null
  183. passwordRequestedAt: null
  184. groups: null
  185. roles: null
  186. }
Add Comment
Please, Sign In to add comment