Guest User

Untitled

a guest
Oct 21st, 2018
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.12 KB | None | 0 0
  1. <?php
  2.  
  3. namespace Yanic\UsersBundle\Entity;
  4.  
  5. use Symfony\Component\Security\Core\User\AdvancedUserInterface;
  6. use Symfony\Component\Security\Core\User\EquatableInterface;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. use Doctrine\ORM\Mapping as ORM;
  9.  
  10. /**
  11. * Yanic\UsersBundle\Entity\Users
  12. *
  13. * @ORM\Table(name="users")
  14. * @ORM\Entity(repositoryClass="Yanic\UsersBundle\Entity\UsersRepository")
  15. */
  16. class Users implements AdvancedUserInterface, EquatableInterface
  17. {
  18. /**
  19. * @var integer $id
  20. *
  21. * @ORM\Column(name="id", type="integer", nullable=false)
  22. * @ORM\Id
  23. * @ORM\GeneratedValue(strategy="IDENTITY")
  24. */
  25. private $id;
  26.  
  27. /**
  28. * @var string $username
  29. *
  30. * @ORM\Column(name="username", type="string", length=32, nullable=true)
  31. */
  32. private $username;
  33.  
  34. /**
  35. * @var string $password
  36. *
  37. * @ORM\Column(name="password", type="string", length=60, nullable=false)
  38. */
  39. private $password;
  40.  
  41. /**
  42. * @var string $salt
  43. *
  44. * @ORM\Column(name="salt", type="string", length=32, nullable=false)
  45. */
  46. private $salt;
  47.  
  48. /**
  49. * @var string $email
  50. *
  51. * @ORM\Column(name="email", type="string", length=100, nullable=true)
  52. */
  53. private $email;
  54.  
  55. /**
  56. * @var datetime $created
  57. *
  58. * @ORM\Column(name="created", type="datetime", nullable=false)
  59. */
  60. private $created;
  61.  
  62. /**
  63. * @var datetime $modified
  64. *
  65. * @ORM\Column(name="modified", type="datetime", nullable=true)
  66. */
  67. private $modified;
  68.  
  69. /**
  70. * @var boolean $isActive
  71. *
  72. * @ORM\Column(name="is_active", type="boolean", nullable=false)
  73. */
  74. private $isActive;
  75.  
  76. /**
  77. * @var datetime $lastLogin
  78. *
  79. * @ORM\Column(name="last_login", type="datetime", nullable=true)
  80. */
  81. private $lastLogin;
  82.  
  83. /**
  84. * @var integer $modifiedBy
  85. *
  86. * @ORM\Column(name="modified_by", type="integer", nullable=true)
  87. */
  88. private $modifiedBy;
  89.  
  90. /**
  91. * @var text $configs
  92. *
  93. * @ORM\Column(name="configs", type="text", nullable=false)
  94. */
  95. private $configs = '';
  96.  
  97. /**
  98. * @ORM\ManyToMany(targetEntity="Roles", inversedBy="users")
  99. * @ORM\JoinTable(name="users_roles")
  100. */
  101. private $groups;
  102.  
  103. public function __construct()
  104. {
  105. $this->isActive = true;
  106. $this->salt = md5(uniqid(null, true));
  107. $this->groups = new ArrayCollection();
  108.  
  109. $inspector = \FirePHP::to('page');
  110. $console = $inspector->console();
  111. $console->info('Users:__construct()');
  112. }
  113.  
  114. /**
  115. * @inheritDoc
  116. */
  117. public function eraseCredentials()
  118. {
  119. }
  120.  
  121. /**
  122. * @inheritDoc
  123. */
  124. function isEqualTo(\Symfony\Component\Security\Core\User\UserInterface $user)
  125. {
  126. $inspector = \FirePHP::to('page');
  127. $console = $inspector->console();
  128. $console->info('Users::isEqualTo()');
  129.  
  130. return $this->username === $user->getUsername();
  131. }
  132.  
  133. /**
  134. * @inheritDoc
  135. */
  136. public function isAccountNonExpired()
  137. {
  138. return true;
  139. }
  140. /**
  141. * @inheritDoc
  142. */
  143. public function isAccountNonLocked()
  144. {
  145. return true;
  146. }
  147. /**
  148. * @inheritDoc
  149. */
  150. public function isCredentialsNonExpired()
  151. {
  152. return true;
  153. }
  154. /**
  155. * @inheritDoc
  156. */
  157. public function isEnabled()
  158. {
  159. return $this->isActive;
  160. }
  161.  
  162. public function __toString()
  163. {
  164. return $this->getId();
  165. }
  166.  
  167. /**
  168. * Add groups
  169. *
  170. * @param Yanic\UsersBundle\Entity\Roles $groups
  171. */
  172. public function addGroup(Roles $groups)
  173. {
  174. $this->groups[] = $groups;
  175. }
  176.  
  177. /**
  178. * Get groups
  179. *
  180. * @return Doctrine\Common\Collections\Collection
  181. */
  182. public function getGroups()
  183. {
  184. return $this->groups;
  185. }
  186.  
  187. /**
  188. * Get id
  189. *
  190. * @return integer
  191. */
  192. public function getId()
  193. {
  194. return $this->id;
  195. }
  196.  
  197. /**
  198. * Set username
  199. *
  200. * @param string $username
  201. */
  202. public function setUsername($username)
  203. {
  204. $this->username = $username;
  205. }
  206.  
  207. /**
  208. * Get username
  209. *
  210. * @return string
  211. */
  212. public function getUsername()
  213. {
  214. $inspector = \FirePHP::to('page');
  215. $console = $inspector->console();
  216. $console->info('Users:getUsername()');
  217.  
  218. return $this->username;
  219. }
  220.  
  221. /**
  222. * Set password
  223. *
  224. * @param string $password
  225. */
  226. public function setPassword($password)
  227. {
  228. $this->password = $password;
  229. }
  230.  
  231. /**
  232. * Get password
  233. *
  234. * @return string
  235. */
  236. public function getPassword()
  237. {
  238. return $this->password;
  239. }
  240.  
  241. /**
  242. * Set salt
  243. *
  244. * @param string $salt
  245. */
  246. public function setSalt($salt)
  247. {
  248. $this->salt = $salt;
  249. }
  250.  
  251. /**
  252. * Get salt
  253. *
  254. * @return string
  255. */
  256. public function getSalt()
  257. {
  258. return $this->salt;
  259. }
  260.  
  261. /**
  262. * Set email
  263. *
  264. * @param string $email
  265. */
  266. public function setEmail($email)
  267. {
  268. $this->email = $email;
  269. }
  270.  
  271. /**
  272. * Get email
  273. *
  274. * @return string
  275. */
  276. public function getEmail()
  277. {
  278. return $this->email;
  279. }
  280.  
  281. /**
  282. * Set created
  283. *
  284. * @param datetime $created
  285. */
  286. public function setCreated($created)
  287. {
  288. $this->created = $created;
  289. }
  290.  
  291. /**
  292. * Get created
  293. *
  294. * @return datetime
  295. */
  296. public function getCreated()
  297. {
  298. return $this->created;
  299. }
  300.  
  301. /**
  302. * Set modified
  303. *
  304. * @param date $modified
  305. */
  306. public function setModified($modified)
  307. {
  308. $this->modified = $modified;
  309. }
  310.  
  311. /**
  312. * Get modified
  313. *
  314. * @return date
  315. */
  316. public function getModified()
  317. {
  318. return $this->modified;
  319. }
  320.  
  321. /**
  322. * Set isActive
  323. *
  324. * @param boolean $isActive
  325. */
  326. public function setIsActive($isActive)
  327. {
  328. $this->isActive = $isActive;
  329. }
  330.  
  331. /**
  332. * Get isActive
  333. *
  334. * @return boolean
  335. */
  336. public function getIsActive()
  337. {
  338. return $this->isActive;
  339. }
  340.  
  341. /**
  342. * Set lastLogin
  343. *
  344. * @param datetime $lastLogin
  345. */
  346. public function setLastLogin($lastLogin)
  347. {
  348. $this->lastLogin = $lastLogin;
  349. }
  350.  
  351. /**
  352. * Get lastLogin
  353. *
  354. * @return datetime
  355. */
  356. public function getLastLogin()
  357. {
  358. return $this->lastLogin;
  359. }
  360.  
  361. /**
  362. * Set modifiedBy
  363. *
  364. * @param integer $modifiedBy
  365. */
  366. public function setModifiedBy($modifiedBy)
  367. {
  368. $this->modifiedBy = $modifiedBy;
  369. }
  370.  
  371. /**
  372. * Get modifiedBy
  373. *
  374. * @return integer
  375. */
  376. public function getModifiedBy()
  377. {
  378. return $this->modifiedBy;
  379. }
  380.  
  381. /**
  382. * Set configs
  383. *
  384. * @param text $configs
  385. */
  386. public function setConfigs($configs)
  387. {
  388. $this->configs = $configs;
  389. }
  390.  
  391. /**
  392. * Get configs
  393. *
  394. * @return text
  395. */
  396. public function getConfigs()
  397. {
  398. return $this->configs;
  399. }
  400.  
  401. /**
  402. * @inheritDoc
  403. */
  404. public function getRoles()
  405. {
  406. return $this->groups->toArray();
  407. }
  408. }
Add Comment
Please, Sign In to add comment