123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 |
- <?php
- /*
- * This file is part of the Sonata project.
- *
- * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
- namespace Sonata\UserBundle\Entity;
- use FOS\UserBundle\Entity\User as AbstractedUser;
- use Sonata\UserBundle\Model\UserInterface;
- /**
- * Represents a Base User Entity
- */
- class BaseUser extends AbstractedUser implements UserInterface
- {
- /**
- * @var \DateTime
- */
- protected $createdAt;
- /**
- * @var \DateTime
- */
- protected $updatedAt;
- /**
- * @var string
- */
- protected $twoStepVerificationCode;
- /**
- * Sets the creation date
- *
- * @param \DateTime|null $createdAt
- */
- public function setCreatedAt(\DateTime $createdAt = null)
- {
- $this->createdAt = $createdAt;
- }
- /**
- * Returns the creation date
- *
- * @return \DateTime|null
- */
- public function getCreatedAt()
- {
- return $this->createdAt;
- }
- /**
- * Sets the last update date
- *
- * @param \DateTime|null $updatedAt
- */
- public function setUpdatedAt(\DateTime $updatedAt = null)
- {
- $this->updatedAt = $updatedAt;
- }
- /**
- * Returns the last update date
- *
- * @return \DateTime|null
- */
- public function getUpdatedAt()
- {
- return $this->updatedAt;
- }
-
- /**
- * Returns the expiration date
- *
- * @return \DateTime|null
- */
- public function getExpiresAt()
- {
- return $this->expiresAt;
- }
- /**
- * Hook on pre-persist operations
- */
- public function prePersist()
- {
- $this->createdAt = new \DateTime;
- $this->updatedAt = new \DateTime;
- }
- /**
- * Hook on pre-update operations
- */
- public function preUpdate()
- {
- $this->updatedAt = new \DateTime;
- }
- /**
- * Returns the credentials expiration date
- *
- * @return \DateTime
- */
- public function getCredentialsExpireAt()
- {
- return $this->credentialsExpireAt;
- }
- /**
- * Sets the credentials expiration date
- *
- * @param \DateTime|null $date
- */
- public function setCredentialsExpireAt(\DateTime $date = null)
- {
- $this->credentialsExpireAt = $date;
- }
- /**
- * Returns a string representation
- *
- * @return string
- */
- public function __toString()
- {
- return $this->getUsername() ?: '-';
- }
- /**
- * Sets the user groups
- *
- * @param array $groups
- */
- public function setGroups($groups)
- {
- foreach ($groups as $group){
- $this->addGroup($group);
- }
- }
- /**
- * Sets the two-step verification code
- *
- * @param string $twoStepVerificationCode
- */
- public function setTwoStepVerificationCode($twoStepVerificationCode)
- {
- $this->twoStepVerificationCode = $twoStepVerificationCode;
- }
- /**
- * Returns the two-step verification code
- *
- * @return string
- */
- public function getTwoStepVerificationCode()
- {
- return $this->twoStepVerificationCode;
- }
- }
|