BaseUser.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /*
  3. * This file is part of the Sonata Project package.
  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\Entity;
  11. use Sonata\UserBundle\Model\User as AbstractedUser;
  12. use Sonata\UserBundle\Model\UserInterface;
  13. /**
  14. * Represents a Base User Entity.
  15. */
  16. class BaseUser extends AbstractedUser
  17. {
  18. /**
  19. * Hook on pre-persist operations.
  20. */
  21. public function prePersist()
  22. {
  23. $this->createdAt = new \DateTime();
  24. $this->updatedAt = new \DateTime();
  25. }
  26. /**
  27. * Hook on pre-update operations.
  28. */
  29. public function preUpdate()
  30. {
  31. $this->updatedAt = new \DateTime();
  32. }
  33. /**
  34. * Returns the gender list.
  35. *
  36. * @return array
  37. */
  38. public static function getGenderList()
  39. {
  40. return array(
  41. UserInterface::GENDER_UNKNOWN => 'gender_unknown',
  42. UserInterface::GENDER_FEMALE => 'gender_female',
  43. UserInterface::GENDER_MALE => 'gender_male',
  44. );
  45. }
  46. }