createdAt = $createdAt; return $this; } /** * Returns createdAt. * * @return \DateTime */ public function getCreatedAt() { return $this->createdAt; } public function __construct() { $this->games = new ArrayCollection(); } /** * Returns the roles granted to the user. * * * public function getRoles() * { * return array('ROLE_USER'); * } * * * Alternatively, the roles might be stored on a ``roles`` property, * and populated in any number of different ways when the user object * is created. * * @return (Role|string)[] The user roles */ public function getRoles() { return ['ROLE_USER']; } /** * Returns the password used to authenticate the user. * * This should be the encoded password. On authentication, a plain-text * password will be salted, encoded, and then compared to this value. * * @return string The password */ public function getPassword() { return null; } /** * Returns the salt that was originally used to encode the password. * * This can return null if the password was not encoded using a salt. * * @return string|null The salt */ public function getSalt() { return null; } /** * Returns the username used to authenticate the user. * * @return string The username */ public function getUsername() { return $this->getId(); } /** * Removes sensitive data from the user. * * This is important if, at any given point, sensitive information like * the plain-text password is stored on this object. */ public function eraseCredentials() { } /** * Gets the value of id. * * @return integer */ public function getId() { return $this->id; } /** * @JMS\VirtualProperty * @return String */ public function getJwt() { $c =Application::getInstance()->getConfig(); $encoder = new JWTEncoder($c['secret_key'], $c['jwt_lifetime'], null); return $encoder->encode(['id' => $this->getUsername()]); } }