Vaya se me olvido el gran User
Código PHP:
<?php
namespace inventariouserBundleEntity;
use DoctrineORMMapping as ORM;
use SymfonyComponentSecurityCoreUserUserInterface;
use SymfonyComponentSecurityCoreUserAdvancedUserInterface;
/* esta linea es para validaciones*/
use SymfonyComponentValidatorConstraints as Assert;
/* esta linea es para que no haya valores repetidos en la tabla*/
use SymfonyBridgeDoctrineValidatorConstraintsUniqueEntity;
use DoctrineCommonCollectionsArrayCollection;
/**
* User
*
* @ORM\Table(name="users")
* @ORM\Entity(repositoryClass="inventario\userBundle\Repository\UserRepository")
* @UniqueEntity("username")
* @UniqueEntity("email")
* @ORM\HasLifecycleCallbacks()
*/
class User implements UserInterface, serializable
{
/**
* @ORM\OneToMany(targetEntity="\inventario\inmueblesBundle\Entity\intervencion", mappedBy="User")
*/
protected $intervencion;
public function __construct()
{
$this->intervencion = new ArrayCollection();
}
/**
* @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=50, unique=true)
* @Assert\NotBlank()
*/
private $username;
/**
* @var string
*
* @ORM\Column(name="primer_apellido", type="string", length=100)
* @Assert\NotBlank()
*/
private $primerApellido;
/**
* @var string
*
* @ORM\Column(name="segundo_apellido", type="string", length=100)
* @Assert\NotBlank()
*/
private $segundoApellido;
/**
* @var string
*
* @ORM\Column(name="email", type="string", length=100, unique=true)
* @Assert\NotBlank()
* @Assert\Email()
*/
private $email;
/**
* @var string
*
* @ORM\Column(name="password", type="string", length=255)
*/
private $password;
/**
* @var string
*
* @ORM\Column(name="role", type="string",columnDefinition="ENUM('ROLE_ADMIN','ROLE_USER')", length=50)
* @Assert\NotBlank()
* @Assert\Choice(choices = {"ROLE_ADMIN", "ROLE_USER"})
*/
private $role;
/**
* @var bool
*
* @ORM\Column(name="is_active", type="boolean")
*
*/
private $isActive;
/**
* @var \DateTime
*
* @ORM\Column(name="created_at", type="datetime")
*/
private $createdAt;
/**
* @var \DateTime
*
* @ORM\Column(name="updated_at", type="datetime")
*/
private $updatedAt;
/**
* 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 primerApellido
*
* @param string $primerApellido
*
* @return User
*/
public function setPrimerApellido($primerApellido)
{
$this->primerApellido = $primerApellido;
return $this;
}
/**
* Get primerApellido
*
* @return string
*/
public function getPrimerApellido()
{
return $this->primerApellido;
}
/**
* Set segundoApellido
*
* @param string $segundoApellido
*
* @return User
*/
public function setSegundoApellido($segundoApellido)
{
$this->segundoApellido = $segundoApellido;
return $this;
}
/**
* Get segundoApellido
*
* @return string
*/
public function getSegundoApellido()
{
return $this->segundoApellido;
}
/**
* Set email
*
* @param string $email
*
* @return User
*/
public function setEmail($email)
{
$this->email = $email;
return $this;
}
/**
* Get email
*
* @return string
*/
public function getEmail()
{
return $this->email;
}
/**
* 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 role
*
* @param string $role
*
* @return User
*/
public function setRole($role)
{
$this->role = $role;
return $this;
}
/**
* Get role
*
* @return string
*/
public function getRole()
{
return $this->role;
}
/**
* Set isActive
*
* @param boolean $isActive
*
* @return User
*/
public function setIsActive($isActive)
{
$this->isActive = $isActive;
return $this;
}
/**
* Get isActive
*
* @return bool
*/
public function getIsActive()
{
return $this->isActive;
}
/**
* Set createdAt
*
* @param \DateTime $createdAt
*
* @return User
*/
public function setCreatedAt($createdAt)
{
$this->createdAt = $createdAt;
return $this;
}
/**
* Get createdAt
*
* @return \DateTime
*/
public function getCreatedAt()
{
return $this->createdAt;
}
/**
* Set updatedAt
*
* @param \DateTime $updatedAt
*
* @return User
*/
public function setUpdatedAt($updatedAt)
{
$this->updatedAt = $updatedAt;
return $this;
}
/**
* Get updatedAt
*
* @return \DateTime
*/
public function getUpdatedAt()
{
return $this->updatedAt;
}
/**
* @ORM\PrePersist
*/
public function setCreatedAtValue()
{
$this->createdAt = new DateTime();
}
/**
* @ORM\PrePersist
* @ORM\PreUpdate
*/
public function setUpdatedAtValue()
{
$this->updatedAt = new DateTime();
}
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 getRoles()
{
return $this->role;
}
/** @see \Serializable::serialize() */
public function serialize()
{
return serialize(array(
$this->id,
$this->username,
$this->password,
// see section on salt below
// $this->salt,
));
}
/** @see \Serializable::unserialize() */
public function unserialize($serialized)
{
list (
$this->id,
$this->username,
$this->password,
// see section on salt below
// $this->salt
) = unserialize($serialized);
}
public function __toString()
{
return $this->getUsername();
}
//////////////////////SEGURIDAD AÑADIDO
public function isAccountNonExpired()
{
return true;
}
public function isAccountNonLocked()
{
return true;
}
public function isCredentialsNonExpired()
{
return true;
}
public function isEnabled()
{
return $this->isActive;
}
}