<?php
declare(strict_types=1);
/*
* This file is part of the Sonata Project package.
*
* (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\Model;
use FOS\UserBundle\Model\User as AbstractedUser;
/**
* Represents a User model.
*/
abstract class User extends AbstractedUser implements UserInterface
{
/**
* @var \DateTime|null
*/
protected $createdAt;
/**
* @var \DateTime|null
*/
protected $updatedAt;
/**
* @var string
*/
protected $twoStepVerificationCode;
/**
* @var \DateTime|null
*/
protected $dateOfBirth;
/**
* @var string
*/
protected $firstname;
/**
* @var string
*/
protected $lastname;
/**
* @var string
*/
protected $website;
/**
* @var string
*/
protected $biography;
/**
* @var string
*/
protected $gender = UserInterface::GENDER_UNKNOWN; // set the default to unknown
/**
* @var string
*/
protected $locale;
/**
* @var string
*/
protected $timezone;
/**
* @var string
*/
protected $phone;
/**
* @var string
*/
protected $facebookUid;
/**
* @var string
*/
protected $facebookName;
/**
* @var string
*/
protected $facebookData;
/**
* @var string
*/
protected $twitterUid;
/**
* @var string
*/
protected $twitterName;
/**
* @var string
*/
protected $twitterData;
/**
* @var string
*/
protected $gplusUid;
/**
* @var string
*/
protected $gplusName;
/**
* @var string
*/
protected $gplusData;
/**
* @var string
*/
protected $token;
/**
* Returns a string representation.
*
* @return string
*/
public function __toString()
{
return $this->getUsername() ?: '-';
}
/**
* {@inheritdoc}
*/
public function setCreatedAt(\DateTime $createdAt = null)
{
$this->createdAt = $createdAt;
return $this;
}
/**
* {@inheritdoc}
*/
public function getCreatedAt()
{
return $this->createdAt;
}
/**
* {@inheritdoc}
*/
public function setUpdatedAt(\DateTime $updatedAt = null)
{
$this->updatedAt = $updatedAt;
return $this;
}
/**
* {@inheritdoc}
*/
public function getUpdatedAt()
{
return $this->updatedAt;
}
/**
* {@inheritdoc}
*/
public function setGroups($groups)
{
foreach ($groups as $group) {
$this->addGroup($group);
}
return $this;
}
/**
* {@inheritdoc}
*/
public function setTwoStepVerificationCode($twoStepVerificationCode)
{
$this->twoStepVerificationCode = $twoStepVerificationCode;
return $this;
}
/**
* {@inheritdoc}
*/
public function getTwoStepVerificationCode()
{
return $this->twoStepVerificationCode;
}
/**
* {@inheritdoc}
*/
public function setBiography($biography)
{
$this->biography = $biography;
return $this;
}
/**
* {@inheritdoc}
*/
public function getBiography()
{
return $this->biography;
}
/**
* {@inheritdoc}
*/
public function setDateOfBirth($dateOfBirth)
{
$this->dateOfBirth = $dateOfBirth;
return $this;
}
/**
* {@inheritdoc}
*/
public function getDateOfBirth()
{
return $this->dateOfBirth;
}
/**
* {@inheritdoc}
*/
public function setFacebookData($facebookData)
{
$this->facebookData = $facebookData;
return $this;
}
/**
* {@inheritdoc}
*/
public function getFacebookData()
{
return $this->facebookData;
}
/**
* {@inheritdoc}
*/
public function setFacebookName($facebookName)
{
$this->facebookName = $facebookName;
return $this;
}
/**
* {@inheritdoc}
*/
public function getFacebookName()
{
return $this->facebookName;
}
/**
* {@inheritdoc}
*/
public function setFacebookUid($facebookUid)
{
$this->facebookUid = $facebookUid;
return $this;
}
/**
* {@inheritdoc}
*/
public function getFacebookUid()
{
return $this->facebookUid;
}
/**
* {@inheritdoc}
*/
public function setFirstname($firstname)
{
$this->firstname = $firstname;
return $this;
}
/**
* {@inheritdoc}
*/
public function getFirstname()
{
return $this->firstname;
}
/**
* {@inheritdoc}
*/
public function setGender($gender)
{
$this->gender = $gender;
return $this;
}
/**
* {@inheritdoc}
*/
public function getGender()
{
return $this->gender;
}
/**
* {@inheritdoc}
*/
public function setGplusData($gplusData)
{
$this->gplusData = $gplusData;
return $this;
}
/**
* {@inheritdoc}
*/
public function getGplusData()
{
return $this->gplusData;
}
/**
* {@inheritdoc}
*/
public function setGplusName($gplusName)
{
$this->gplusName = $gplusName;
return $this;
}
/**
* {@inheritdoc}
*/
public function getGplusName()
{
return $this->gplusName;
}
/**
* {@inheritdoc}
*/
public function setGplusUid($gplusUid)
{
$this->gplusUid = $gplusUid;
return $this;
}
/**
* {@inheritdoc}
*/
public function getGplusUid()
{
return $this->gplusUid;
}
/**
* {@inheritdoc}
*/
public function setLastname($lastname)
{
$this->lastname = $lastname;
return $this;
}
/**
* {@inheritdoc}
*/
public function getLastname()
{
return $this->lastname;
}
/**
* {@inheritdoc}
*/
public function setLocale($locale)
{
$this->locale = $locale;
return $this;
}
/**
* {@inheritdoc}
*/
public function getLocale()
{
return $this->locale;
}
/**
* {@inheritdoc}
*/
public function setPhone($phone)
{
$this->phone = $phone;
return $this;
}
/**
* {@inheritdoc}
*/
public function getPhone()
{
return $this->phone;
}
/**
* {@inheritdoc}
*/
public function setTimezone($timezone)
{
$this->timezone = $timezone;
return $this;
}
/**
* {@inheritdoc}
*/
public function getTimezone()
{
return $this->timezone;
}
/**
* {@inheritdoc}
*/
public function setTwitterData($twitterData)
{
$this->twitterData = $twitterData;
return $this;
}
/**
* {@inheritdoc}
*/
public function getTwitterData()
{
return $this->twitterData;
}
/**
* {@inheritdoc}
*/
public function setTwitterName($twitterName)
{
$this->twitterName = $twitterName;
return $this;
}
/**
* {@inheritdoc}
*/
public function getTwitterName()
{
return $this->twitterName;
}
/**
* {@inheritdoc}
*/
public function setTwitterUid($twitterUid)
{
$this->twitterUid = $twitterUid;
return $this;
}
/**
* {@inheritdoc}
*/
public function getTwitterUid()
{
return $this->twitterUid;
}
/**
* {@inheritdoc}
*/
public function setWebsite($website)
{
$this->website = $website;
return $this;
}
/**
* {@inheritdoc}
*/
public function getWebsite()
{
return $this->website;
}
/**
* {@inheritdoc}
*/
public function setToken($token)
{
$this->token = $token;
return $this;
}
/**
* {@inheritdoc}
*/
public function getToken()
{
return $this->token;
}
/**
* {@inheritdoc}
*/
public function getFullname()
{
return sprintf('%s %s', $this->getFirstname(), $this->getLastname());
}
/**
* {@inheritdoc}
*/
public function getRealRoles()
{
return $this->roles;
}
/**
* {@inheritdoc}
*/
public function setRealRoles(array $roles)
{
$this->setRoles($roles);
return $this;
}
/**
* Returns the gender list.
*
* @return array
*/
public static function getGenderList()
{
return [
'gender_unknown' => UserInterface::GENDER_UNKNOWN,
'gender_female' => UserInterface::GENDER_FEMALE,
'gender_male' => UserInterface::GENDER_MALE,
];
}
}