vendor/sonata-project/user-bundle/src/Model/User.php line 21

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. /*
  4.  * This file is part of the Sonata Project package.
  5.  *
  6.  * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
  7.  *
  8.  * For the full copyright and license information, please view the LICENSE
  9.  * file that was distributed with this source code.
  10.  */
  11. namespace Sonata\UserBundle\Model;
  12. use FOS\UserBundle\Model\User as AbstractedUser;
  13. /**
  14.  * Represents a User model.
  15.  */
  16. abstract class User extends AbstractedUser implements UserInterface
  17. {
  18.     /**
  19.      * @var \DateTime|null
  20.      */
  21.     protected $createdAt;
  22.     /**
  23.      * @var \DateTime|null
  24.      */
  25.     protected $updatedAt;
  26.     /**
  27.      * @var string
  28.      */
  29.     protected $twoStepVerificationCode;
  30.     /**
  31.      * @var \DateTime|null
  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 UserInterface::GENDER_UNKNOWN// set the default to unknown
  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.      * Returns a string representation.
  108.      *
  109.      * @return string
  110.      */
  111.     public function __toString()
  112.     {
  113.         return $this->getUsername() ?: '-';
  114.     }
  115.     /**
  116.      * {@inheritdoc}
  117.      */
  118.     public function setCreatedAt(\DateTime $createdAt null)
  119.     {
  120.         $this->createdAt $createdAt;
  121.         return $this;
  122.     }
  123.     /**
  124.      * {@inheritdoc}
  125.      */
  126.     public function getCreatedAt()
  127.     {
  128.         return $this->createdAt;
  129.     }
  130.     /**
  131.      * {@inheritdoc}
  132.      */
  133.     public function setUpdatedAt(\DateTime $updatedAt null)
  134.     {
  135.         $this->updatedAt $updatedAt;
  136.         return $this;
  137.     }
  138.     /**
  139.      * {@inheritdoc}
  140.      */
  141.     public function getUpdatedAt()
  142.     {
  143.         return $this->updatedAt;
  144.     }
  145.     /**
  146.      * {@inheritdoc}
  147.      */
  148.     public function setGroups($groups)
  149.     {
  150.         foreach ($groups as $group) {
  151.             $this->addGroup($group);
  152.         }
  153.         return $this;
  154.     }
  155.     /**
  156.      * {@inheritdoc}
  157.      */
  158.     public function setTwoStepVerificationCode($twoStepVerificationCode)
  159.     {
  160.         $this->twoStepVerificationCode $twoStepVerificationCode;
  161.         return $this;
  162.     }
  163.     /**
  164.      * {@inheritdoc}
  165.      */
  166.     public function getTwoStepVerificationCode()
  167.     {
  168.         return $this->twoStepVerificationCode;
  169.     }
  170.     /**
  171.      * {@inheritdoc}
  172.      */
  173.     public function setBiography($biography)
  174.     {
  175.         $this->biography $biography;
  176.         return $this;
  177.     }
  178.     /**
  179.      * {@inheritdoc}
  180.      */
  181.     public function getBiography()
  182.     {
  183.         return $this->biography;
  184.     }
  185.     /**
  186.      * {@inheritdoc}
  187.      */
  188.     public function setDateOfBirth($dateOfBirth)
  189.     {
  190.         $this->dateOfBirth $dateOfBirth;
  191.         return $this;
  192.     }
  193.     /**
  194.      * {@inheritdoc}
  195.      */
  196.     public function getDateOfBirth()
  197.     {
  198.         return $this->dateOfBirth;
  199.     }
  200.     /**
  201.      * {@inheritdoc}
  202.      */
  203.     public function setFacebookData($facebookData)
  204.     {
  205.         $this->facebookData $facebookData;
  206.         return $this;
  207.     }
  208.     /**
  209.      * {@inheritdoc}
  210.      */
  211.     public function getFacebookData()
  212.     {
  213.         return $this->facebookData;
  214.     }
  215.     /**
  216.      * {@inheritdoc}
  217.      */
  218.     public function setFacebookName($facebookName)
  219.     {
  220.         $this->facebookName $facebookName;
  221.         return $this;
  222.     }
  223.     /**
  224.      * {@inheritdoc}
  225.      */
  226.     public function getFacebookName()
  227.     {
  228.         return $this->facebookName;
  229.     }
  230.     /**
  231.      * {@inheritdoc}
  232.      */
  233.     public function setFacebookUid($facebookUid)
  234.     {
  235.         $this->facebookUid $facebookUid;
  236.         return $this;
  237.     }
  238.     /**
  239.      * {@inheritdoc}
  240.      */
  241.     public function getFacebookUid()
  242.     {
  243.         return $this->facebookUid;
  244.     }
  245.     /**
  246.      * {@inheritdoc}
  247.      */
  248.     public function setFirstname($firstname)
  249.     {
  250.         $this->firstname $firstname;
  251.         return $this;
  252.     }
  253.     /**
  254.      * {@inheritdoc}
  255.      */
  256.     public function getFirstname()
  257.     {
  258.         return $this->firstname;
  259.     }
  260.     /**
  261.      * {@inheritdoc}
  262.      */
  263.     public function setGender($gender)
  264.     {
  265.         $this->gender $gender;
  266.         return $this;
  267.     }
  268.     /**
  269.      * {@inheritdoc}
  270.      */
  271.     public function getGender()
  272.     {
  273.         return $this->gender;
  274.     }
  275.     /**
  276.      * {@inheritdoc}
  277.      */
  278.     public function setGplusData($gplusData)
  279.     {
  280.         $this->gplusData $gplusData;
  281.         return $this;
  282.     }
  283.     /**
  284.      * {@inheritdoc}
  285.      */
  286.     public function getGplusData()
  287.     {
  288.         return $this->gplusData;
  289.     }
  290.     /**
  291.      * {@inheritdoc}
  292.      */
  293.     public function setGplusName($gplusName)
  294.     {
  295.         $this->gplusName $gplusName;
  296.         return $this;
  297.     }
  298.     /**
  299.      * {@inheritdoc}
  300.      */
  301.     public function getGplusName()
  302.     {
  303.         return $this->gplusName;
  304.     }
  305.     /**
  306.      * {@inheritdoc}
  307.      */
  308.     public function setGplusUid($gplusUid)
  309.     {
  310.         $this->gplusUid $gplusUid;
  311.         return $this;
  312.     }
  313.     /**
  314.      * {@inheritdoc}
  315.      */
  316.     public function getGplusUid()
  317.     {
  318.         return $this->gplusUid;
  319.     }
  320.     /**
  321.      * {@inheritdoc}
  322.      */
  323.     public function setLastname($lastname)
  324.     {
  325.         $this->lastname $lastname;
  326.         return $this;
  327.     }
  328.     /**
  329.      * {@inheritdoc}
  330.      */
  331.     public function getLastname()
  332.     {
  333.         return $this->lastname;
  334.     }
  335.     /**
  336.      * {@inheritdoc}
  337.      */
  338.     public function setLocale($locale)
  339.     {
  340.         $this->locale $locale;
  341.         return $this;
  342.     }
  343.     /**
  344.      * {@inheritdoc}
  345.      */
  346.     public function getLocale()
  347.     {
  348.         return $this->locale;
  349.     }
  350.     /**
  351.      * {@inheritdoc}
  352.      */
  353.     public function setPhone($phone)
  354.     {
  355.         $this->phone $phone;
  356.         return $this;
  357.     }
  358.     /**
  359.      * {@inheritdoc}
  360.      */
  361.     public function getPhone()
  362.     {
  363.         return $this->phone;
  364.     }
  365.     /**
  366.      * {@inheritdoc}
  367.      */
  368.     public function setTimezone($timezone)
  369.     {
  370.         $this->timezone $timezone;
  371.         return $this;
  372.     }
  373.     /**
  374.      * {@inheritdoc}
  375.      */
  376.     public function getTimezone()
  377.     {
  378.         return $this->timezone;
  379.     }
  380.     /**
  381.      * {@inheritdoc}
  382.      */
  383.     public function setTwitterData($twitterData)
  384.     {
  385.         $this->twitterData $twitterData;
  386.         return $this;
  387.     }
  388.     /**
  389.      * {@inheritdoc}
  390.      */
  391.     public function getTwitterData()
  392.     {
  393.         return $this->twitterData;
  394.     }
  395.     /**
  396.      * {@inheritdoc}
  397.      */
  398.     public function setTwitterName($twitterName)
  399.     {
  400.         $this->twitterName $twitterName;
  401.         return $this;
  402.     }
  403.     /**
  404.      * {@inheritdoc}
  405.      */
  406.     public function getTwitterName()
  407.     {
  408.         return $this->twitterName;
  409.     }
  410.     /**
  411.      * {@inheritdoc}
  412.      */
  413.     public function setTwitterUid($twitterUid)
  414.     {
  415.         $this->twitterUid $twitterUid;
  416.         return $this;
  417.     }
  418.     /**
  419.      * {@inheritdoc}
  420.      */
  421.     public function getTwitterUid()
  422.     {
  423.         return $this->twitterUid;
  424.     }
  425.     /**
  426.      * {@inheritdoc}
  427.      */
  428.     public function setWebsite($website)
  429.     {
  430.         $this->website $website;
  431.         return $this;
  432.     }
  433.     /**
  434.      * {@inheritdoc}
  435.      */
  436.     public function getWebsite()
  437.     {
  438.         return $this->website;
  439.     }
  440.     /**
  441.      * {@inheritdoc}
  442.      */
  443.     public function setToken($token)
  444.     {
  445.         $this->token $token;
  446.         return $this;
  447.     }
  448.     /**
  449.      * {@inheritdoc}
  450.      */
  451.     public function getToken()
  452.     {
  453.         return $this->token;
  454.     }
  455.     /**
  456.      * {@inheritdoc}
  457.      */
  458.     public function getFullname()
  459.     {
  460.         return sprintf('%s %s'$this->getFirstname(), $this->getLastname());
  461.     }
  462.     /**
  463.      * {@inheritdoc}
  464.      */
  465.     public function getRealRoles()
  466.     {
  467.         return $this->roles;
  468.     }
  469.     /**
  470.      * {@inheritdoc}
  471.      */
  472.     public function setRealRoles(array $roles)
  473.     {
  474.         $this->setRoles($roles);
  475.         return $this;
  476.     }
  477.     /**
  478.      * Returns the gender list.
  479.      *
  480.      * @return array
  481.      */
  482.     public static function getGenderList()
  483.     {
  484.         return [
  485.             'gender_unknown' => UserInterface::GENDER_UNKNOWN,
  486.             'gender_female' => UserInterface::GENDER_FEMALE,
  487.             'gender_male' => UserInterface::GENDER_MALE,
  488.         ];
  489.     }
  490. }