PageRenderTime 25ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/vendor/sonata-project/user-bundle/Model/User.php

https://gitlab.com/freebird/WebApp
PHP | 585 lines | 244 code | 79 blank | 262 comment | 0 complexity | c5345ff22985d82b3c071da6f2f1d6d1 MD5 | raw file
  1. <?php
  2. /*
  3. * This file is part of the Sonata project.
  4. *
  5. * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Sonata\UserBundle\Model;
  11. use FOS\UserBundle\Entity\User as AbstractedUser;
  12. use Sonata\UserBundle\Model\UserInterface;
  13. /**
  14. * Represents a User model
  15. */
  16. abstract class User extends AbstractedUser implements UserInterface
  17. {
  18. /**
  19. * @var \DateTime
  20. */
  21. protected $createdAt;
  22. /**
  23. * @var \DateTime
  24. */
  25. protected $updatedAt;
  26. /**
  27. * @var string
  28. */
  29. protected $twoStepVerificationCode;
  30. /**
  31. * @var \DateTime
  32. */
  33. protected $dateOfBirth;
  34. /**
  35. * @var string
  36. */
  37. protected $firstname;
  38. /**
  39. * @var string
  40. */
  41. protected $lastname;
  42. /**
  43. * @var string
  44. */
  45. protected $website;
  46. /**
  47. * @var string
  48. */
  49. protected $biography;
  50. /**
  51. * @var string
  52. */
  53. protected $gender = UserInterface::GENDER_UNKNOWN; // set the default to unknown
  54. /**
  55. * @var string
  56. */
  57. protected $locale;
  58. /**
  59. * @var string
  60. */
  61. protected $timezone;
  62. /**
  63. * @var string
  64. */
  65. protected $phone;
  66. /**
  67. * @var string
  68. */
  69. protected $facebookUid;
  70. /**
  71. * @var string
  72. */
  73. protected $facebookName;
  74. /**
  75. * @var string
  76. */
  77. protected $facebookData;
  78. /**
  79. * @var string
  80. */
  81. protected $twitterUid;
  82. /**
  83. * @var string
  84. */
  85. protected $twitterName;
  86. /**
  87. * @var string
  88. */
  89. protected $twitterData;
  90. /**
  91. * @var string
  92. */
  93. protected $gplusUid;
  94. /**
  95. * @var string
  96. */
  97. protected $gplusName;
  98. /**
  99. * @var string
  100. */
  101. protected $gplusData;
  102. /**
  103. * @var string
  104. */
  105. protected $token;
  106. /**
  107. * Sets the creation date
  108. *
  109. * @param \DateTime|null $createdAt
  110. */
  111. public function setCreatedAt(\DateTime $createdAt = null)
  112. {
  113. $this->createdAt = $createdAt;
  114. }
  115. /**
  116. * Returns the creation date
  117. *
  118. * @return \DateTime|null
  119. */
  120. public function getCreatedAt()
  121. {
  122. return $this->createdAt;
  123. }
  124. /**
  125. * Sets the last update date
  126. *
  127. * @param \DateTime|null $updatedAt
  128. */
  129. public function setUpdatedAt(\DateTime $updatedAt = null)
  130. {
  131. $this->updatedAt = $updatedAt;
  132. }
  133. /**
  134. * Returns the last update date
  135. *
  136. * @return \DateTime|null
  137. */
  138. public function getUpdatedAt()
  139. {
  140. return $this->updatedAt;
  141. }
  142. /**
  143. * Returns the expiration date
  144. *
  145. * @return \DateTime|null
  146. */
  147. public function getExpiresAt()
  148. {
  149. return $this->expiresAt;
  150. }
  151. /**
  152. * Set expiration date
  153. *
  154. * @param \DateTime|null $date
  155. *
  156. * @return User
  157. */
  158. public function setExpiresAt(\DateTime $date = null)
  159. {
  160. $this->expiresAt = $date;
  161. return $this;
  162. }
  163. /**
  164. * Returns the credentials expiration date
  165. *
  166. * @return \DateTime
  167. */
  168. public function getCredentialsExpireAt()
  169. {
  170. return $this->credentialsExpireAt;
  171. }
  172. /**
  173. * Sets the credentials expiration date
  174. *
  175. * @param \DateTime|null $date
  176. */
  177. public function setCredentialsExpireAt(\DateTime $date = null)
  178. {
  179. $this->credentialsExpireAt = $date;
  180. }
  181. /**
  182. * Returns a string representation
  183. *
  184. * @return string
  185. */
  186. public function __toString()
  187. {
  188. return $this->getUsername() ?: '-';
  189. }
  190. /**
  191. * Sets the user groups
  192. *
  193. * @param array $groups
  194. */
  195. public function setGroups($groups)
  196. {
  197. foreach ($groups as $group) {
  198. $this->addGroup($group);
  199. }
  200. }
  201. /**
  202. * Sets the two-step verification code
  203. *
  204. * @param string $twoStepVerificationCode
  205. */
  206. public function setTwoStepVerificationCode($twoStepVerificationCode)
  207. {
  208. $this->twoStepVerificationCode = $twoStepVerificationCode;
  209. }
  210. /**
  211. * Returns the two-step verification code
  212. *
  213. * @return string
  214. */
  215. public function getTwoStepVerificationCode()
  216. {
  217. return $this->twoStepVerificationCode;
  218. }
  219. /**
  220. * @param string $biography
  221. */
  222. public function setBiography($biography)
  223. {
  224. $this->biography = $biography;
  225. }
  226. /**
  227. * @return string
  228. */
  229. public function getBiography()
  230. {
  231. return $this->biography;
  232. }
  233. /**
  234. * @param \DateTime $dateOfBirth
  235. */
  236. public function setDateOfBirth($dateOfBirth)
  237. {
  238. $this->dateOfBirth = $dateOfBirth;
  239. }
  240. /**
  241. * @return \DateTime
  242. */
  243. public function getDateOfBirth()
  244. {
  245. return $this->dateOfBirth;
  246. }
  247. /**
  248. * @param string $facebookData
  249. */
  250. public function setFacebookData($facebookData)
  251. {
  252. $this->facebookData = $facebookData;
  253. }
  254. /**
  255. * @return string
  256. */
  257. public function getFacebookData()
  258. {
  259. return $this->facebookData;
  260. }
  261. /**
  262. * @param string $facebookName
  263. */
  264. public function setFacebookName($facebookName)
  265. {
  266. $this->facebookName = $facebookName;
  267. }
  268. /**
  269. * @return string
  270. */
  271. public function getFacebookName()
  272. {
  273. return $this->facebookName;
  274. }
  275. /**
  276. * @param string $facebookUid
  277. */
  278. public function setFacebookUid($facebookUid)
  279. {
  280. $this->facebookUid = $facebookUid;
  281. }
  282. /**
  283. * @return string
  284. */
  285. public function getFacebookUid()
  286. {
  287. return $this->facebookUid;
  288. }
  289. /**
  290. * @param string $firstname
  291. */
  292. public function setFirstname($firstname)
  293. {
  294. $this->firstname = $firstname;
  295. }
  296. /**
  297. * @return string
  298. */
  299. public function getFirstname()
  300. {
  301. return $this->firstname;
  302. }
  303. /**
  304. * @param string $gender
  305. */
  306. public function setGender($gender)
  307. {
  308. $this->gender = $gender;
  309. }
  310. /**
  311. * @return string
  312. */
  313. public function getGender()
  314. {
  315. return $this->gender;
  316. }
  317. /**
  318. * @param string $gplusData
  319. */
  320. public function setGplusData($gplusData)
  321. {
  322. $this->gplusData = $gplusData;
  323. }
  324. /**
  325. * @return string
  326. */
  327. public function getGplusData()
  328. {
  329. return $this->gplusData;
  330. }
  331. /**
  332. * @param string $gplusName
  333. */
  334. public function setGplusName($gplusName)
  335. {
  336. $this->gplusName = $gplusName;
  337. }
  338. /**
  339. * @return string
  340. */
  341. public function getGplusName()
  342. {
  343. return $this->gplusName;
  344. }
  345. /**
  346. * @param string $gplusUid
  347. */
  348. public function setGplusUid($gplusUid)
  349. {
  350. $this->gplusUid = $gplusUid;
  351. }
  352. /**
  353. * @return string
  354. */
  355. public function getGplusUid()
  356. {
  357. return $this->gplusUid;
  358. }
  359. /**
  360. * @param string $lastname
  361. */
  362. public function setLastname($lastname)
  363. {
  364. $this->lastname = $lastname;
  365. }
  366. /**
  367. * @return string
  368. */
  369. public function getLastname()
  370. {
  371. return $this->lastname;
  372. }
  373. /**
  374. * @param string $locale
  375. */
  376. public function setLocale($locale)
  377. {
  378. $this->locale = $locale;
  379. }
  380. /**
  381. * @return string
  382. */
  383. public function getLocale()
  384. {
  385. return $this->locale;
  386. }
  387. /**
  388. * @param string $phone
  389. */
  390. public function setPhone($phone)
  391. {
  392. $this->phone = $phone;
  393. }
  394. /**
  395. * @return string
  396. */
  397. public function getPhone()
  398. {
  399. return $this->phone;
  400. }
  401. /**
  402. * @param string $timezone
  403. */
  404. public function setTimezone($timezone)
  405. {
  406. $this->timezone = $timezone;
  407. }
  408. /**
  409. * @return string
  410. */
  411. public function getTimezone()
  412. {
  413. return $this->timezone;
  414. }
  415. /**
  416. * @param string $twitterData
  417. */
  418. public function setTwitterData($twitterData)
  419. {
  420. $this->twitterData = $twitterData;
  421. }
  422. /**
  423. * @return string
  424. */
  425. public function getTwitterData()
  426. {
  427. return $this->twitterData;
  428. }
  429. /**
  430. * @param string $twitterName
  431. */
  432. public function setTwitterName($twitterName)
  433. {
  434. $this->twitterName = $twitterName;
  435. }
  436. /**
  437. * @return string
  438. */
  439. public function getTwitterName()
  440. {
  441. return $this->twitterName;
  442. }
  443. /**
  444. * @param string $twitterUid
  445. */
  446. public function setTwitterUid($twitterUid)
  447. {
  448. $this->twitterUid = $twitterUid;
  449. }
  450. /**
  451. * @return string
  452. */
  453. public function getTwitterUid()
  454. {
  455. return $this->twitterUid;
  456. }
  457. /**
  458. * @param string $website
  459. */
  460. public function setWebsite($website)
  461. {
  462. $this->website = $website;
  463. }
  464. /**
  465. * @return string
  466. */
  467. public function getWebsite()
  468. {
  469. return $this->website;
  470. }
  471. /**
  472. * @param string $token
  473. */
  474. public function setToken($token)
  475. {
  476. $this->token = $token;
  477. }
  478. /**
  479. * @return string
  480. */
  481. public function getToken()
  482. {
  483. return $this->token;
  484. }
  485. /**
  486. * @return string
  487. */
  488. public function getFullname()
  489. {
  490. return sprintf("%s %s", $this->getFirstname(), $this->getLastname());
  491. }
  492. /**
  493. * @return array
  494. */
  495. public function getRealRoles()
  496. {
  497. return $this->roles;
  498. }
  499. /**
  500. * @param array $roles
  501. */
  502. public function setRealRoles(array $roles)
  503. {
  504. $this->setRoles($roles);
  505. }
  506. }