* * 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; } }