Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace App\Entity;
- use Doctrine\ORM\Mapping as ORM;
- use Symfony\Component\Validator\Constraints as Assert;
- use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
- use Symfony\Component\Security\Core\User\UserInterface;
- /**
- * @ORM\Entity
- * @UniqueEntity(fields="id", message="id already taken")
- * @UniqueEntity(fields="email", message="Email already taken")
- * @UniqueEntity(fields="username", message="Username already taken")
- */
- class User implements UserInterface
- {
- /**
- * @ORM\Id
- * @ORM\Column(type="integer")
- * @ORM\GeneratedValue(strategy="AUTO")
- */
- private $id;
- /**
- * @ORM\Column(type="string", length=255, unique=true)
- * @Assert\NotBlank()
- * @Assert\Email()
- */
- private $email;
- /**
- * @ORM\Column(type="string", length=255, unique=true)
- * @Assert\NotBlank()
- */
- private $username;
- /**
- * @Assert\NotBlank()
- * @Assert\Length(max=4096)
- */
- private $plainPassword;
- /**
- * The below length depends on the "algorithm" you use for encoding
- * the password, but this works well with bcrypt.
- *
- * @ORM\Column(type="string", length=64)
- */
- private $password;
- /**
- * @ORM\Column(type="array")
- */
- private $roles;
- /**
- * User constructor.
- */
- public function __construct()
- {
- $this->roles = array('ROLE_USER');
- }
- // other properties and methods
- /**
- * @return mixed
- */
- public function getId()
- {
- return $this->id;
- }
- /**
- * @return mixed
- */
- public function getEmail()
- {
- return $this->email;
- }
- /**
- * @param $email
- */
- public function setEmail($email)
- {
- $this->email = $email;
- }
- /**
- * @return string
- */
- public function getUsername()
- {
- return $this->username;
- }
- /**
- * @param $username
- */
- public function setUsername($username)
- {
- $this->username = $username;
- }
- /**
- * @return mixed
- */
- public function getPlainPassword()
- {
- return $this->plainPassword;
- }
- /**
- * @param $password
- */
- public function setPlainPassword($password)
- {
- $this->plainPassword = $password;
- }
- /**
- * @return string
- */
- public function getPassword()
- {
- return $this->password;
- }
- /**
- * @param $password
- */
- public function setPassword($password)
- {
- $this->password = $password;
- }
- /**
- * @return string|null
- */
- public function getSalt()
- {
- // The bcrypt and argon2i algorithms don't require a separate salt.
- // You *may* need a real salt if you choose a different encoder.
- return null;
- }
- /**
- * @return array
- */
- public function getRoles()
- {
- return $this->roles;
- }
- /**
- *
- */
- public function eraseCredentials()
- {
- }
- }
Add Comment
Please, Sign In to add comment