Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace ImmoWebBundle\Entity;
- use Doctrine\ORM\Mapping as ORM;
- use Symfony\Component\Security\Core\User\AdvancedUserInterface;
- use Symfony\Component\Validator\Constraints as Assert;
- use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
- /**
- * Class Person
- *
- * @ORM\Entity(repositoryClass="ImmoWebBundle\Entity\PersonRepository")
- * @ORM\Table(name="persons")
- * @ORM\HasLifecycleCallbacks
- *
- * @package ImmoWebBundle\Entity
- */
- class Person implements AdvancedUserInterface, \Serializable
- {
- use IdTrait, NameAndSlugTrait, TimestampTrait;
- const ROLE_ADMIN = 'ROLE_ADMIN';
- const ROLE_USER = 'ROLE_USER';
- /**
- * @ORM\Column(type="string", length=100, unique=true)
- * @Assert\NotBlank()
- * @Assert\Email()
- */
- protected $emailAddress;
- /**
- * @ORM\Column(type="string", length=64, nullable=true)
- */
- protected $password;
- /**
- * @Assert\NotBlank()
- * @Assert\Length(max=4096)
- */
- protected $plainPassword;
- /**
- * @ORM\Column(type="string", length=15)
- */
- protected $role = self::ROLE_USER;
- /**
- * @ORM\Column(type="boolean")
- */
- protected $active = true;
- /**
- * Set emailAddress
- *
- * @param string $emailAddress
- *
- * @return Person
- */
- public function setEmailAddress($emailAddress)
- {
- $this->emailAddress = $emailAddress;
- return $this;
- }
- /**
- * Get emailAddress
- *
- * @return string
- */
- public function getEmailAddress()
- {
- return $this->emailAddress;
- }
- /**
- * Set password
- *
- * @param string $password
- *
- * @return Person
- */
- public function setPassword($password)
- {
- $this->password = password_hash($password, PASSWORD_BCRYPT);
- return $this;
- }
- /**
- * Get password
- *
- * @return string
- */
- public function getPassword()
- {
- return $this->password;
- }
- /**
- * @return mixed
- */
- public function getPlainPassword()
- {
- return $this->plainPassword;
- }
- /**
- * @param mixed $plainPassword
- *
- * @return $this
- */
- public function setPlainPassword($plainPassword)
- {
- $this->plainPassword = $plainPassword;
- return $this;
- }
- /**
- * Set role
- *
- * @param string $role
- *
- * @return $this
- */
- public function setRole($role)
- {
- $this->role = $role;
- return $this;
- }
- /**
- * Get role
- *
- * @return string
- */
- public function getRole()
- {
- return $this->role;
- }
- public function serialize()
- {
- return serialize(array(
- $this->id,
- $this->slug,
- $this->password
- ));
- }
- public function unserialize($serialized)
- {
- list (
- $this->id,
- $this->slug,
- $this->password
- ) = unserialize($serialized);
- }
- public function getRoles()
- {
- return [$this->getRole()];
- }
- public function getSalt()
- {
- return null;
- }
- public function getUsername()
- {
- return $this->emailAddress;
- }
- public function eraseCredentials()
- {
- // TODO: Implement eraseCredentials() method.
- }
- public function isAccountNonExpired()
- {
- return true;
- }
- public function isAccountNonLocked()
- {
- return true;
- }
- public function isCredentialsNonExpired()
- {
- return true;
- }
- public function isEnabled()
- {
- return $this->active;
- }
- /**
- * Set active
- *
- * @param boolean $active
- *
- * @return Person
- */
- public function setActive($active)
- {
- $this->active = $active;
- return $this;
- }
- /**
- * Get active
- *
- * @return boolean
- */
- public function getActive()
- {
- return $this->active;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement