src/Entity/User.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use App\Utility\AdvancedUserInterface;
  5. use Symfony\Component\Security\Core\User\EquatableInterface;
  6. use Symfony\Component\Security\Core\User\UserInterface;
  7. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  8. /**
  9.  * User
  10.  *
  11.  * @ORM\Table(name="user_acm", uniqueConstraints={@ORM\UniqueConstraint(name="UNIQ_USER1", columns={"username"})})
  12.  * @ORM\Entity(repositoryClass="App\Repository\UserRepository")
  13.  */
  14. class User implements AdvancedUserInterface\SerializableEquatableInterfacePasswordAuthenticatedUserInterface
  15. {
  16.     /**
  17.      * @var string
  18.      *
  19.      * @ORM\Column(name="username", type="string", length=25, nullable=false)
  20.      */
  21.     private $username;
  22.     /**
  23.      * @var string
  24.      *
  25.      * @ORM\Column(name="salt", type="string", length=32, nullable=true)
  26.      */
  27.     private $salt;
  28.     /**
  29.      * @var string
  30.      *
  31.      * @ORM\Column(name="text1", type="string", length=255, nullable=false)
  32.      */
  33.     private $password;
  34.     /**
  35.      * @var string
  36.      *
  37.      * @ORM\Column(name="email", type="string", length=60, nullable=false)
  38.      */
  39.     private $email;
  40.     /**
  41.      * @var string
  42.      *
  43.      * @ORM\Column(name="first_name", type="string", length=50, nullable=false)
  44.      */
  45.     private $firstName;
  46.     /**
  47.      * @var string
  48.      *
  49.      * @ORM\Column(name="last_name", type="string", length=50, nullable=false)
  50.      */
  51.     private $lastName;
  52.     /**
  53.      * @var string
  54.      *
  55.      * @ORM\Column(name="user_role", type="string", length=50, nullable=false)
  56.      */
  57.     private $userRole;
  58.     /**
  59.      * @var boolean
  60.      *
  61.      * @ORM\Column(name="change_text1", type="boolean", nullable=false)
  62.      */
  63.     private $changePassword;
  64.     /**
  65.      * @var boolean
  66.      *
  67.      * @ORM\Column(name="status", type="boolean", nullable=false)
  68.      */
  69.     private $status;
  70.     /**
  71.      * @var boolean
  72.      *
  73.      * @ORM\Column(name="flag_token", type="boolean", nullable=false)
  74.      */
  75.     private $flag_token;
  76.     /**
  77.      * @var integer
  78.      *
  79.      * @ORM\Column(name="id", type="integer")
  80.      * @ORM\Id
  81.      * @ORM\GeneratedValue(strategy="IDENTITY")
  82.      */
  83.     private $id;
  84.     /**
  85.      * Set username
  86.      *
  87.      * @param string $username
  88.      *
  89.      * @return User
  90.      */
  91.     public function setUsername($username)
  92.     {
  93.         $this->username $username;
  94.         return $this;
  95.     }
  96.     /**
  97.      * Get username
  98.      *
  99.      * @return string
  100.      */
  101.     public function getUsername()
  102.     {
  103.         return $this->username;
  104.     }
  105.     /**
  106.      * Set salt
  107.      *
  108.      * @param string $salt
  109.      *
  110.      * @return User
  111.      */
  112.     public function setSalt($salt)
  113.     {
  114.         $this->salt $salt;
  115.         return $this;
  116.     }
  117.     /**
  118.      * Get salt
  119.      *
  120.      * @return string
  121.      */
  122.     public function getSalt()
  123.     {
  124.         return $this->salt;
  125.     }
  126.     /**
  127.      * Set password
  128.      *
  129.      * @param string $password
  130.      *
  131.      * @return User
  132.      */
  133.     public function setPassword($password)
  134.     {
  135.         $this->password $password;
  136.         return $this;
  137.     }
  138.     /**
  139.      * Get password
  140.      *
  141.      * @return string
  142.      */
  143.     public function getPassword() : ?string
  144.     {
  145.         return $this->password;
  146.     }
  147.     /**
  148.      * Set email
  149.      *
  150.      * @param string $email
  151.      *
  152.      * @return User
  153.      */
  154.     public function setEmail($email)
  155.     {
  156.         $this->email $email;
  157.         return $this;
  158.     }
  159.     /**
  160.      * Get email
  161.      *
  162.      * @return string
  163.      */
  164.     public function getEmail()
  165.     {
  166.         return $this->email;
  167.     }
  168.     /**
  169.      * Set firstName
  170.      *
  171.      * @param string $firstName
  172.      *
  173.      * @return User
  174.      */
  175.     public function setFirstName($firstName)
  176.     {
  177.         $this->firstName $firstName;
  178.         return $this;
  179.     }
  180.     /**
  181.      * Get firstName
  182.      *
  183.      * @return string
  184.      */
  185.     public function getFirstName()
  186.     {
  187.         return $this->firstName;
  188.     }
  189.     /**
  190.      * Set lastName
  191.      *
  192.      * @param string $lastName
  193.      *
  194.      * @return User
  195.      */
  196.     public function setLastName($lastName)
  197.     {
  198.         $this->lastName $lastName;
  199.         return $this;
  200.     }
  201.     /**
  202.      * Get lastName
  203.      *
  204.      * @return string
  205.      */
  206.     public function getLastName()
  207.     {
  208.         return $this->lastName;
  209.     }
  210.     /**
  211.      * Set userRole
  212.      *
  213.      * @param string $userRole
  214.      *
  215.      * @return User
  216.      */
  217.     public function setUserRole($userRole)
  218.     {
  219.         $this->userRole $userRole;
  220.         return $this;
  221.     }
  222.     /**
  223.      * Get userRole
  224.      *
  225.      * @return string
  226.      */
  227.     public function getUserRole()
  228.     {
  229.         return $this->userRole;
  230.     }
  231.     /**
  232.      * Set changePassword
  233.      *
  234.      * @param boolean $changePassword
  235.      *
  236.      * @return User
  237.      */
  238.     public function setChangePassword($changePassword)
  239.     {
  240.         $this->changePassword $changePassword;
  241.         return $this;
  242.     }
  243.     /**
  244.      * Get changePassword
  245.      *
  246.      * @return boolean
  247.      */
  248.     public function getChangePassword()
  249.     {
  250.         return $this->changePassword;
  251.     }
  252.     /**
  253.      * Set status
  254.      *
  255.      * @param boolean $status
  256.      *
  257.      * @return User
  258.      */
  259.     public function setStatus($status)
  260.     {
  261.         $this->status $status;
  262.         return $this;
  263.     }
  264.     /**
  265.      * Get status
  266.      *
  267.      * @return boolean
  268.      */
  269.     public function getStatus()
  270.     {
  271.         return $this->status;
  272.     }
  273.     /**
  274.      * Set flag_token
  275.      *
  276.      * @param boolean $flag_token
  277.      *
  278.      * @return User
  279.      */
  280.     public function setFlagToken($flag_token)
  281.     {
  282.         $this->flag_token $flag_token;
  283.         return $this;
  284.     }
  285.     /**
  286.      * Get flag_token
  287.      *
  288.      * @return boolean
  289.      */
  290.     public function getFlagToken()
  291.     {
  292.         return $this->flag_token;
  293.     }
  294.     /**
  295.      * Get id
  296.      *
  297.      * @return integer
  298.      */
  299.     public function getId()
  300.     {
  301.         return $this->id;
  302.     }
  303.     public function isAccountNonExpired()
  304.     {
  305.         return true;
  306.     }
  307.     public function isAccountNonLocked()
  308.     {
  309.         return ($this->status == 1);
  310.     }
  311.     public function isCredentialsNonExpired()
  312.     {
  313.         return true;
  314.     }
  315.     public function isEnabled()
  316.     {
  317.         return ($this->status == 1);
  318.     }
  319.     public function getRoles()
  320.     {
  321.         return array($this->userRole);
  322.     }
  323.     /** @see \Serializable::serialize() */
  324.     public function serialize()
  325.     {
  326.         return serialize(array(
  327.             $this->id,
  328.             $this->username,
  329.             $this->password,
  330.             // see section on salt below
  331.             // $this->salt,
  332.         ));
  333.     }
  334.     /** @see \Serializable::unserialize() */
  335.     public function unserialize($serialized)
  336.     {
  337.         list (
  338.             $this->id,
  339.             $this->username,
  340.             $this->password,
  341.             // see section on salt below
  342.             // $this->salt
  343.         ) = unserialize($serialized);
  344.     }
  345.     public function eraseCredentials()
  346.     {
  347.     }
  348.     public function isEqualTo(UserInterface $user)
  349.     {
  350.         if ($this->password !== $user->getPassword()) {
  351.             return false;
  352.         }
  353.         if ($this->salt != $user->getSalt()) {
  354.             return false;
  355.         }
  356.         if ($this->username !== $user->getUsername()) {
  357.             return false;
  358.         }
  359.         return true;
  360.     }    
  361. }