User.php 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555
  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;
  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. * Returns the credentials expiration date
  153. *
  154. * @return \DateTime
  155. */
  156. public function getCredentialsExpireAt()
  157. {
  158. return $this->credentialsExpireAt;
  159. }
  160. /**
  161. * Sets the credentials expiration date
  162. *
  163. * @param \DateTime|null $date
  164. */
  165. public function setCredentialsExpireAt(\DateTime $date = null)
  166. {
  167. $this->credentialsExpireAt = $date;
  168. }
  169. /**
  170. * Returns a string representation
  171. *
  172. * @return string
  173. */
  174. public function __toString()
  175. {
  176. return $this->getUsername() ?: '-';
  177. }
  178. /**
  179. * Sets the user groups
  180. *
  181. * @param array $groups
  182. */
  183. public function setGroups($groups)
  184. {
  185. foreach ($groups as $group) {
  186. $this->addGroup($group);
  187. }
  188. }
  189. /**
  190. * Sets the two-step verification code
  191. *
  192. * @param string $twoStepVerificationCode
  193. */
  194. public function setTwoStepVerificationCode($twoStepVerificationCode)
  195. {
  196. $this->twoStepVerificationCode = $twoStepVerificationCode;
  197. }
  198. /**
  199. * Returns the two-step verification code
  200. *
  201. * @return string
  202. */
  203. public function getTwoStepVerificationCode()
  204. {
  205. return $this->twoStepVerificationCode;
  206. }
  207. /**
  208. * @param string $biography
  209. */
  210. public function setBiography($biography)
  211. {
  212. $this->biography = $biography;
  213. }
  214. /**
  215. * @return string
  216. */
  217. public function getBiography()
  218. {
  219. return $this->biography;
  220. }
  221. /**
  222. * @param \DateTime $dateOfBirth
  223. */
  224. public function setDateOfBirth($dateOfBirth)
  225. {
  226. $this->dateOfBirth = $dateOfBirth;
  227. }
  228. /**
  229. * @return \DateTime
  230. */
  231. public function getDateOfBirth()
  232. {
  233. return $this->dateOfBirth;
  234. }
  235. /**
  236. * @param string $facebookData
  237. */
  238. public function setFacebookData($facebookData)
  239. {
  240. $this->facebookData = $facebookData;
  241. }
  242. /**
  243. * @return string
  244. */
  245. public function getFacebookData()
  246. {
  247. return $this->facebookData;
  248. }
  249. /**
  250. * @param string $facebookName
  251. */
  252. public function setFacebookName($facebookName)
  253. {
  254. $this->facebookName = $facebookName;
  255. }
  256. /**
  257. * @return string
  258. */
  259. public function getFacebookName()
  260. {
  261. return $this->facebookName;
  262. }
  263. /**
  264. * @param string $facebookUid
  265. */
  266. public function setFacebookUid($facebookUid)
  267. {
  268. $this->facebookUid = $facebookUid;
  269. }
  270. /**
  271. * @return string
  272. */
  273. public function getFacebookUid()
  274. {
  275. return $this->facebookUid;
  276. }
  277. /**
  278. * @param string $firstname
  279. */
  280. public function setFirstname($firstname)
  281. {
  282. $this->firstname = $firstname;
  283. }
  284. /**
  285. * @return string
  286. */
  287. public function getFirstname()
  288. {
  289. return $this->firstname;
  290. }
  291. /**
  292. * @param string $gender
  293. */
  294. public function setGender($gender)
  295. {
  296. $this->gender = $gender;
  297. }
  298. /**
  299. * @return string
  300. */
  301. public function getGender()
  302. {
  303. return $this->gender;
  304. }
  305. /**
  306. * @param string $gplusData
  307. */
  308. public function setGplusData($gplusData)
  309. {
  310. $this->gplusData = $gplusData;
  311. }
  312. /**
  313. * @return string
  314. */
  315. public function getGplusData()
  316. {
  317. return $this->gplusData;
  318. }
  319. /**
  320. * @param string $gplusName
  321. */
  322. public function setGplusName($gplusName)
  323. {
  324. $this->gplusName = $gplusName;
  325. }
  326. /**
  327. * @return string
  328. */
  329. public function getGplusName()
  330. {
  331. return $this->gplusName;
  332. }
  333. /**
  334. * @param string $gplusUid
  335. */
  336. public function setGplusUid($gplusUid)
  337. {
  338. $this->gplusUid = $gplusUid;
  339. }
  340. /**
  341. * @return string
  342. */
  343. public function getGplusUid()
  344. {
  345. return $this->gplusUid;
  346. }
  347. /**
  348. * @param string $lastname
  349. */
  350. public function setLastname($lastname)
  351. {
  352. $this->lastname = $lastname;
  353. }
  354. /**
  355. * @return string
  356. */
  357. public function getLastname()
  358. {
  359. return $this->lastname;
  360. }
  361. /**
  362. * @param string $locale
  363. */
  364. public function setLocale($locale)
  365. {
  366. $this->locale = $locale;
  367. }
  368. /**
  369. * @return string
  370. */
  371. public function getLocale()
  372. {
  373. return $this->locale;
  374. }
  375. /**
  376. * @param string $phone
  377. */
  378. public function setPhone($phone)
  379. {
  380. $this->phone = $phone;
  381. }
  382. /**
  383. * @return string
  384. */
  385. public function getPhone()
  386. {
  387. return $this->phone;
  388. }
  389. /**
  390. * @param string $timezone
  391. */
  392. public function setTimezone($timezone)
  393. {
  394. $this->timezone = $timezone;
  395. }
  396. /**
  397. * @return string
  398. */
  399. public function getTimezone()
  400. {
  401. return $this->timezone;
  402. }
  403. /**
  404. * @param string $twitterData
  405. */
  406. public function setTwitterData($twitterData)
  407. {
  408. $this->twitterData = $twitterData;
  409. }
  410. /**
  411. * @return string
  412. */
  413. public function getTwitterData()
  414. {
  415. return $this->twitterData;
  416. }
  417. /**
  418. * @param string $twitterName
  419. */
  420. public function setTwitterName($twitterName)
  421. {
  422. $this->twitterName = $twitterName;
  423. }
  424. /**
  425. * @return string
  426. */
  427. public function getTwitterName()
  428. {
  429. return $this->twitterName;
  430. }
  431. /**
  432. * @param string $twitterUid
  433. */
  434. public function setTwitterUid($twitterUid)
  435. {
  436. $this->twitterUid = $twitterUid;
  437. }
  438. /**
  439. * @return string
  440. */
  441. public function getTwitterUid()
  442. {
  443. return $this->twitterUid;
  444. }
  445. /**
  446. * @param string $website
  447. */
  448. public function setWebsite($website)
  449. {
  450. $this->website = $website;
  451. }
  452. /**
  453. * @return string
  454. */
  455. public function getWebsite()
  456. {
  457. return $this->website;
  458. }
  459. /**
  460. * @param string $token
  461. */
  462. public function setToken($token)
  463. {
  464. $this->token = $token;
  465. }
  466. /**
  467. * @return string
  468. */
  469. public function getToken()
  470. {
  471. return $this->token;
  472. }
  473. /**
  474. * @return string
  475. */
  476. public function getFullname()
  477. {
  478. return sprintf("%s %s", $this->getFirstname(), $this->getLastname());
  479. }
  480. }