Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace App\Entity;
- use ApiPlatform\Core\Annotation\ApiResource;
- use Doctrine\ORM\Mapping as ORM;
- use Symfony\Component\Security\Core\User\UserInterface;
- /**
- * A user with an account (admin + traveler ftm).
- * @ApiResource
- * @ORM\Entity
- */
- class Account implements UserInterface, \Serializable
- {
- /**
- * @var int id
- *
- * @ORM\Id
- * @ORM\GeneratedValue
- * @ORM\Column(type="integer")
- */
- protected $id;
- /**
- * @var string firstname
- *
- * @ORM\Column(type="text")
- */
- protected $firstname;
- /**
- * @var string lastname
- *
- * @ORM\Column(type="text")
- */
- protected $lastname;
- /**
- * @var string email
- *
- * @ORM\Column(type="text")
- */
- protected $email;
- /**
- * @var string username
- *
- * @ORM\Column(type="text")
- */
- protected $username;
- /**
- * @var string password
- *
- * @ORM\Column(type="text")
- */
- protected $password;
- /**
- * @var string role
- *
- * @ORM\Column(type="text")
- */
- protected $role;
- /**
- * @ORM\Column(name="is_active", type="boolean")
- */
- private $isActive;
- public function __construct()
- {
- $this->isActive = true;
- // may not be needed, see section on salt below
- // $this->salt = md5(uniqid('', true));
- }
- public function getId(): ?int
- {
- return $this->id;
- }
- /**
- * Returns the username used to authenticate the user.
- *
- * @return string The username
- */
- public function getUsername()
- {
- return $this->username;
- }
- /**
- * @return string
- */
- public function getFirstname(): string
- {
- return $this->firstname;
- }
- /**
- * @param string $firstname
- */
- public function setFirstname(string $firstname): void
- {
- $this->firstname = $firstname;
- }
- /**
- * @return string
- */
- public function getLastname(): string
- {
- return $this->lastname;
- }
- /**
- * @param string $lastname
- */
- public function setLastname(string $lastname): void
- {
- $this->lastname = $lastname;
- }
- /**
- * @return string
- */
- public function getEmail(): string
- {
- return $this->email;
- }
- /**
- * @param string $email
- */
- public function setEmail(string $email): void
- {
- $this->email = $email;
- $this->username = $email;
- }
- /**
- * @return string
- */
- public function getPassword(): string
- {
- return $this->password;
- }
- public function getSalt()
- {
- // you *may* need a real salt depending on your encoder
- // see section on salt below
- return null;
- }
- /**
- * @param string $password
- */
- public function setPassword(string $password): void
- {
- $this->password = $password;
- }
- /**
- * @return string
- */
- public function getRoles(): string
- {
- return $this->role;
- }
- /**
- * @param string $role
- */
- public function setRole(string $role): void
- {
- $this->role = $role;
- }
- /** @see \Serializable::serialize() */
- public function serialize()
- {
- return serialize(array(
- $this->id,
- $this->email,
- $this->password,
- // see section on salt below
- // $this->salt,
- ));
- }
- /** @see \Serializable::unserialize() */
- public function unserialize($serialized)
- {
- list (
- $this->id,
- $this->email,
- $this->password,
- // see section on salt below
- // $this->salt
- ) = unserialize($serialized);
- }
- /**
- * 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()
- {
- // TODO: Implement eraseCredentials() method.
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement