Guest User

Untitled

a guest
Nov 23rd, 2018
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.95 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=100, nullable=true)
  31. */
  32. private $username;
  33.  
  34. /**
  35. * @var string $password
  36. *
  37. * @ORM\Column(name="password", type="string", length=200, 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. * @ORM\OneToOne(targetEntity="Yanic\UsersBundle\Entity\Users")
  85. */
  86. private $modifiedBy;
  87.  
  88. /**
  89. * @var text $configs
  90. *
  91. * @ORM\Column(name="configs", type="text", nullable=false)
  92. */
  93. private $configs = '';
  94.  
  95. /**
  96. * @ORM\ManyToMany(targetEntity="Roles", inversedBy="users")
  97. * @ORM\JoinTable(name="users_roles")
  98. */
  99. private $groups;
  100.  
  101. public function __construct()
  102. {
  103. $logging = false;
  104.  
  105. $this->isActive = true;
  106. $this->salt = md5(uniqid(null, true));
  107. $this->groups = new ArrayCollection();
  108.  
  109. if( $logging && class_exists( 'FirePHP' ) ):
  110. $inspector = \FirePHP::to('page');
  111. $console = $inspector->console();
  112. $console->info('Users:__construct()');
  113. endif;
  114. }
  115.  
  116. /**
  117. * @inheritDoc
  118. */
  119. public function eraseCredentials()
  120. {
  121. }
  122.  
  123. /**
  124. * @inheritDoc
  125. */
  126. function isEqualTo(\Symfony\Component\Security\Core\User\UserInterface $user)
  127. {
  128. $inspector = \FirePHP::to('page');
  129. $console = $inspector->console();
  130. $console->info('Users::isEqualTo()');
  131.  
  132. return $this->username === $user->getUsername();
  133. }
  134.  
  135. /**
  136. * @inheritDoc
  137. */
  138. public function isAccountNonExpired()
  139. {
  140. $inspector = \FirePHP::to('page');
  141. $console = $inspector->console();
  142. $console->info( 'Users:' . __METHOD__ );
  143.  
  144. return true;
  145. }
  146. /**
  147. * @inheritDoc
  148. */
  149. public function isAccountNonLocked()
  150. {
  151. $inspector = \FirePHP::to('page');
  152. $console = $inspector->console();
  153. $console->info( 'Users:' . __METHOD__ );
  154.  
  155. return true;
  156. }
  157. /**
  158. * @inheritDoc
  159. */
  160. public function isCredentialsNonExpired()
  161. {
  162. $inspector = \FirePHP::to('page');
  163. $console = $inspector->console();
  164. $console->info( 'Users:' . __METHOD__ );
  165.  
  166. return true;
  167. }
  168. /**
  169. * @inheritDoc
  170. */
  171. public function isEnabled()
  172. {
  173. $inspector = \FirePHP::to('page');
  174. $console = $inspector->console();
  175. $console->info( 'Users:' . __METHOD__ );
  176.  
  177. return $this->isActive;
  178. }
  179.  
  180. public function __toString()
  181. {
  182. $inspector = \FirePHP::to('page');
  183. $console = $inspector->console();
  184. $console->info('Users:__toString()');
  185.  
  186. return $this->getUsername();
  187. }
  188.  
  189. /**
  190. * Add groups
  191. *
  192. * @param Yanic\UsersBundle\Entity\Roles $groups
  193. */
  194. public function addGroup(Roles $groups)
  195. {
  196. $this->groups[] = $groups;
  197. }
  198.  
  199. /**
  200. * Get groups
  201. *
  202. * @return Doctrine\Common\Collections\Collection
  203. */
  204. public function getGroups()
  205. {
  206. return $this->groups;
  207. }
  208.  
  209. /**
  210. * Get id
  211. *
  212. * @return integer
  213. */
  214. public function getId()
  215. {
  216. return $this->id;
  217. }
  218.  
  219. /**
  220. * Set username
  221. *
  222. * @param string $username
  223. */
  224. public function setUsername($username)
  225. {
  226. $this->username = $username;
  227. }
  228.  
  229. /**
  230. * Get username
  231. *
  232. * @return string
  233. */
  234. public function getUsername()
  235. {
  236. $inspector = \FirePHP::to('page');
  237. $console = $inspector->console();
  238. $console->info('Users:getUsername()');
  239.  
  240. return $this->username;
  241. }
  242.  
  243. /**
  244. * Set password
  245. *
  246. * @param string $password
  247. */
  248. public function setPassword($password)
  249. {
  250. $this->password = $password;
  251. }
  252.  
  253. /**
  254. * Get password
  255. *
  256. * @return string
  257. */
  258. public function getPassword()
  259. {
  260. $inspector = \FirePHP::to('page');
  261. $console = $inspector->console();
  262. $console->info('Password: ' . $this->password );
  263.  
  264. return $this->password;
  265. }
  266.  
  267. /**
  268. * Set salt
  269. *
  270. * @param string $salt
  271. */
  272. public function setSalt($salt)
  273. {
  274. $this->salt = $salt;
  275. }
  276.  
  277. /**
  278. * Get salt
  279. *
  280. * @return string
  281. */
  282. public function getSalt()
  283. {
  284. return $this->salt;
  285. }
  286.  
  287. /**
  288. * Set email
  289. *
  290. * @param string $email
  291. */
  292. public function setEmail($email)
  293. {
  294. $this->email = $email;
  295. }
  296.  
  297. /**
  298. * Get email
  299. *
  300. * @return string
  301. */
  302. public function getEmail()
  303. {
  304. return $this->email;
  305. }
  306.  
  307. /**
  308. * Set created
  309. *
  310. * @param datetime $created
  311. */
  312. public function setCreated($created)
  313. {
  314. $this->created = $created;
  315. }
  316.  
  317. /**
  318. * Get created
  319. *
  320. * @return datetime
  321. */
  322. public function getCreated()
  323. {
  324. return $this->created;
  325. }
  326.  
  327. /**
  328. * Set modified
  329. *
  330. * @param date $modified
  331. */
  332. public function setModified($modified)
  333. {
  334. $this->modified = $modified;
  335. }
  336.  
  337. /**
  338. * Get modified
  339. *
  340. * @return date
  341. */
  342. public function getModified()
  343. {
  344. return $this->modified;
  345. }
  346.  
  347. /**
  348. * Set isActive
  349. *
  350. * @param boolean $isActive
  351. */
  352. public function setIsActive($isActive)
  353. {
  354. $this->isActive = $isActive;
  355. }
  356.  
  357. /**
  358. * Get isActive
  359. *
  360. * @return boolean
  361. */
  362. public function getIsActive()
  363. {
  364. return $this->isActive;
  365. }
  366.  
  367. /**
  368. * Set lastLogin
  369. *
  370. * @param datetime $lastLogin
  371. */
  372. public function setLastLogin($lastLogin)
  373. {
  374. $this->lastLogin = $lastLogin;
  375. }
  376.  
  377. /**
  378. * Get lastLogin
  379. *
  380. * @return datetime
  381. */
  382. public function getLastLogin()
  383. {
  384. return $this->lastLogin;
  385. }
  386.  
  387. /**
  388. * Set modifiedBy
  389. *
  390. * @param integer $modifiedBy
  391. */
  392. public function setModifiedBy($modifiedBy)
  393. {
  394. $this->modifiedBy = $modifiedBy;
  395. }
  396.  
  397. /**
  398. * Get modifiedBy
  399. *
  400. * @return integer
  401. */
  402. public function getModifiedBy()
  403. {
  404. return $this->modifiedBy;
  405. }
  406.  
  407. /**
  408. * Set configs
  409. *
  410. * @param text $configs
  411. */
  412. public function setConfigs($configs)
  413. {
  414. $this->configs = $configs;
  415. }
  416.  
  417. /**
  418. * Get configs
  419. *
  420. * @return text
  421. */
  422. public function getConfigs()
  423. {
  424. return $this->configs;
  425. }
  426.  
  427. /**
  428. * @inheritDoc
  429. */
  430. public function getRoles()
  431. {
  432. return $this->groups->toArray();
  433. }
  434. }
Add Comment
Please, Sign In to add comment