<?php
namespace Mm\Beton\Planungsatlas\AtlasBundle\Entity\User;
use Mm\Beton\Planungsatlas\AtlasBundle\Repository\UserRepository;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass=UserRepository::class)
* @ORM\Table(name="wdvs_pa_users")
* @UniqueEntity(fields="username", message="Email already exists")
*/
class User implements UserInterface, \Serializable
{
/**
* @var integer
*
* @ORM\Column(name="user_id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="user_email", type="string", length=255)
* @Assert\NotBlank
* @Assert\Email
*/
private $username;
/**
* @var string
*
* @ORM\Column(name="user_password", type="string", length=255)
*/
private $password;
/**
* @ORM\Column(type="array")
*/
private $roles;
/**
* @var boolean
*
* @ORM\Column(name="is_active", type="boolean")
*/
private $isActive = false;
/**
* @var \DateTime
*
* @ORM\Column(name="user_registration_datetime", type="datetime", nullable=true)
*/
private $registeredAt;
/**
* @var \DateTime
*
* @ORM\Column(name="last_login_at", type="datetime", nullable=true)
*/
private $lastLoginAt;
/**
* @var string
*
* @ORM\Column(name="user_hash", type="string", length=255)
*/
private $hash = '';
public function __construct() {
$this->roles = [ 'ROLE_USER' ];
}
/**
* Get id
*
* @return integer
*/
public function getId() {
return $this->id;
}
/**
* @param int $id
*
* @return User
*/
public function setId( int $id ) {
$this->id = $id;
return $this;
}
/**
* 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 isActive
*
* @param boolean $isActive
*
* @return User
*/
public function setIsActive( $isActive ) {
$this->isActive = $isActive;
return $this;
}
/**
* Get isActive
*
* @return boolean
*/
public function getIsActive() {
return $this->isActive;
}
/**
* Set registeredAt
*
* @param \DateTime $registeredAt
*
* @return User
*/
public function setRegisteredAt( $registeredAt ) {
$this->registeredAt = $registeredAt;
return $this;
}
/**
* Get registeredAt
*
* @return \DateTime
*/
public function getRegisteredAt() {
return $this->registeredAt;
}
/**
* Set lastLoginAt
*
* @param \DateTime $lastLoginAt
*
* @return User
*/
public function setLastLoginAt( $lastLoginAt ) {
$this->lastLoginAt = $lastLoginAt;
return $this;
}
/**
* Get lastLoginAt
*
* @return \DateTime
*/
public function getLastLoginAt() {
return $this->lastLoginAt;
}
// /**
// * @param UserCart $cart
// *
// * @return User
// */
// public function setCart( UserCart $cart ) {
// $this->cart = $cart;
//
// return $this;
// }
//
// /**
// * @return UserCart
// */
// public function getCart() {
// return $this->cart;
// }
/**
* Set hash
*
* @param string $hash
*
* @return User
*/
public function setHash( $hash ) {
$this->hash = $hash;
return $this;
}
/**
* Get hash
*
* @return string
*/
public function getHash() {
return $this->hash;
}
public function getRoles() {
return [ 'ROLE_USER' ];
}
public function getSalt() {
// you *may* need a real salt depending on your encoder
// see section on salt below
return null;
}
public function eraseCredentials() {
}
public function isAccountNonExpired()
{
return true;
}
public function isAccountNonLocked()
{
return true;
}
public function isCredentialsNonExpired()
{
return true;
}
public function isEnabled()
{
return $this->isActive;
}
/** @see \Serializable::serialize() */
public function serialize() {
return serialize( [
$this->id,
$this->username,
$this->password,
$this->isActive,
] );
}
/** @see \Serializable::unserialize() */
public function unserialize( $serialized ) {
list (
$this->id,
$this->username,
$this->password,
$this->isActive,
) = unserialize( $serialized, [ 'allowed_classes' => false ] );
}
}