Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace MyBlogBundle\Entity;
- use Doctrine\Common\Collections\ArrayCollection;
- use Doctrine\Common\Collections\Collection;
- use Doctrine\ORM\Mapping as ORM;
- use Serializable;
- use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
- use Symfony\Component\Security\Core\User\UserInterface;
- /**
- * User
- *
- * @ORM\Table(name="users")
- * @ORM\Entity(repositoryClass="MyBlogBundle\Repository\UserRepository")
- */
- class User implements UserInterface, Serializable
- {
- /**
- * @var int
- *
- * @ORM\Column(name="id", type="integer")
- * @ORM\Id
- * @ORM\GeneratedValue(strategy="AUTO")
- */
- private $id;
- /**
- * @var string
- *
- * @ORM\Column(name="username", type="string", length=255, unique=true)
- */
- private $username;
- /**
- * @var string
- *
- * @ORM\Column(name="password", type="string", length=255)
- */
- private $password;
- /**
- * @var string
- *
- * @ORM\Column(name="email", type="string", length=255, unique=true)
- */
- private $email;
- /**
- * @var string
- *
- * @ORM\Column(name="fullName", type="string", length=255)
- */
- private $fullName;
- /**
- * @var string
- *
- * @ORM\Column(name="age", type="string", length=255)
- */
- private $age;
- /**
- * @var string
- */
- private $plainPassword;
- /**
- * @var Role
- * @ORM\ManyToMany(targetEntity="MyBlogBundle\Entity\Role")
- * @ORM\JoinTable(name="users_roles",
- * joinColumns={@ORM\JoinColumn(name="user_id", referencedColumnName="id")},
- * inverseJoinColumns={@ORM\JoinColumn(name="role_id", referencedColumnName="id")})
- */
- private $roles;
- /**
- * User constructor.
- */
- public function __construct()
- {
- $this->roles = new ArrayCollection();
- }
- /**
- * @return string
- */
- public function getPlainPassword(): ?string
- {
- return $this->plainPassword;
- }
- /**
- * @param string $plainPassword
- */
- public function setPlainPassword(string $plainPassword)
- {
- $this->plainPassword = $plainPassword;
- }
- /**
- * Get id
- *
- * @return int
- */
- public function getId()
- {
- return $this->id;
- }
- /**
- * Set username
- *
- * @param string $username
- *
- * @return User
- */
- public function setUsername($username)
- {
- $this->username = $username;
- return $this;
- }
- /**
- * Get username
- *
- * @return string
- */
- public function getUsername()
- {
- return $this->username;
- }
- /**
- * Set password
- *
- * @param string $password
- *
- * @return User
- */
- public function setPassword($password)
- {
- $this->password = $password;
- return $this;
- }
- /**
- * Get password
- *
- * @return string
- */
- public function getPassword()
- {
- return $this->password;
- }
- /**
- * Set email
- *
- * @param string $email
- *
- * @return User
- */
- public function setEmail($email)
- {
- $this->email = $email;
- }
- /**
- * Get email
- *
- * @return string
- */
- public function getEmail()
- {
- return $this->email;
- }
- /**
- * Set fullName
- *
- * @param string $fullName
- *
- * @return User
- */
- public function setFullName($fullName)
- {
- $this->fullName = $fullName;
- return $this;
- }
- /**
- * Get fullName
- *
- * @return string
- */
- public function getFullName()
- {
- return $this->fullName;
- }
- /**
- * Set age
- *
- * @param string $age
- *
- * @return User
- */
- public function setAge($age)
- {
- $this->age = $age;
- return $this;
- }
- /**
- * Get age
- *
- * @return string
- */
- public function getAge()
- {
- return $this->age;
- }
- /**
- * @param array $roles
- * @return $this
- */
- public function setRoles(array $roles)
- {
- $this->roles = $roles;
- return $this;
- }
- public function getRoles()
- {
- $roles = [];
- foreach ($this->roles as $role){
- $roles[] = $role->getName();
- }
- return $roles;
- }
- public function getSalt()
- {
- // TODO: Implement getSalt() method.
- }
- public function eraseCredentials()
- {
- // TODO: Implement eraseCredentials() method.
- }
- public function serialize()
- {
- return serialize([$this->getId(),
- $this->getUsername(),
- $this->getPassword()]);
- }
- public function unserialize($serialized)
- {
- list(
- $this->id,
- $this->username,
- $this->password
- ) = unserialize($serialized);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement