Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace Acme\MyBundle\Entity;
- use Symfony\Component\Security\Core\User\UserInterface;
- use Doctrine\ORM\Mapping as ORM;
- use Symfony\Component\Security\Core\User\AdvancedUserInterface;
- use Doctrine\Common\Collections\ArrayCollection;
- /**
- * @ORM\Entity
- * @ORM\Table(name="Users")
- */
- class User implements UserInterface, AdvancedUserInterface, \Serializable
- {
- // Definizione campi
- /**
- * @ORM\Id
- * @ORM\Column(type="integer")
- * @ORM\GeneratedValue(strategy="AUTO")
- */
- protected $id;
- /**
- * @ORM\Column(type="string", unique=true)
- */
- protected $username;
- /**
- * @ORM\Column(type="string")
- */
- protected $password;
- /**
- * @ORM\Column(type="string")
- */
- protected $salt;
- /**
- * @var \Doctrine\Common\Collections\Collection
- *
- * @ORM\ManyToMany(targetEntity="Role", inversedBy="users")
- * @ORM\JoinTable(name="User_Role",
- * joinColumns={
- * @ORM\JoinColumn(name="user_id", referencedColumnName="id")
- * },
- * inverseJoinColumns={
- * @ORM\JoinColumn(name="role_id", referencedColumnName="id")
- * }
- * )
- */
- private $roles;
- /**
- * @ORM\Column(type="integer", nullable=true)
- */
- protected $idAnagrafica;
- /**
- * @ORM\Column(type="integer", nullable=true)
- */
- protected $idTipoVisita;
- /**
- * @ORM\Column(type="boolean", nullable=true)
- */
- protected $attivo;
- // Definizioni delle funzioni Get
- /**
- * @return integer
- */
- public function getId()
- {
- return $this->id;
- }
- /**
- * @return string
- */
- public function getUsername()
- {
- return $this->username;
- }
- /**
- * @return string
- */
- public function getPassword()
- {
- return $this->password;
- }
- /**
- * @return string
- */
- public function getSalt()
- {
- if (null === $this->salt)
- {
- $this->salt = sha512(sprintf('%s_%d_%f',uniqid(),rand(0, 99999),microtime(true)));
- }
- return $this->salt;
- }
- /**
- * @return array
- */
- public function getRoles()
- {
- return $this->roles->toArray();
- }
- /**
- * @return integer
- */
- public function getIdRole()
- {
- return $this->idRole;
- }
- /**
- * @return integer
- */
- public function getIdAnagrafica()
- {
- return $this->idAnagrafica;
- }
- /**
- * @return integer
- */
- public function getIdTipoVisita()
- {
- return $this->idTipoVisita;
- }
- /**
- * @return boolean
- */
- public function getAttivo()
- {
- return $this->attivo;
- }
- public function getUserroles()
- {
- return $this->roles;
- }
- // Definizione delle funzioni Set
- /**
- * @return void
- */
- public function eraseCredentials()
- {
- $this->roles = null;
- }
- /**
- * Set username
- *
- * @param string $username
- * @return User
- */
- public function setUsername($username)
- {
- $this->username = $username;
- return $this;
- }
- /**
- * Set password
- *
- * @param string $password
- * @return User
- */
- public function setPassword($password)
- {
- $this->password = $password;
- return $this;
- }
- /**
- * Set salt
- *
- * @param string $salt
- * @return User
- */
- public function setSalt($salt)
- {
- $this->salt = $salt;
- return $this;
- }
- /**
- * Set idAnagrafica
- *
- * @param integer $idAnagrafica
- * @return User
- */
- public function setIdAnagrafica($idAnagrafica)
- {
- $this->idAnagrafica = $idAnagrafica;
- return $this;
- }
- /**
- * Set riferimento idTipoVisita
- *
- * @param integer $idTipoVisita
- * @return User
- */
- public function setIdTipoVisita($idTipoVisita)
- {
- $this->idTipoVisita = $idTipoVisita;
- return $this;
- }
- /**
- * Set attivo
- *
- * @param boolean $attivo
- * @return User
- */
- public function setAttivo($attivo)
- {
- $this->attivo = $attivo;
- return $this;
- }
- public function setUserroles($roles)
- {
- $this->roles = $roles;
- return $this;
- }
- // Funzioni di servizio
- public function __construct()
- {
- $this->roles = new ArrayCollection();
- }
- /**
- * @see \Serializable::serialize()
- */
- public function serialize()
- {
- return serialize(array($this->id,));
- }
- /**
- * @see \Serializable::unserialize()
- */
- public function unserialize($serialized)
- {
- list ($this->id,) = unserialize($serialized);
- }
- // Funzioni advance user interface
- public function isAccountNonExpired()
- {
- return true;
- }
- public function isAccountNonLocked()
- {
- return true;
- }
- public function isCredentialsNonExpired()
- {
- return true;
- }
- public function isEnabled()
- {
- return $this->attivo;
- }
- //Funzioni autogenerate
- /**
- * Add roles
- *
- * @param \Acme\MyBundle\Entity\Role $roles
- * @return User
- */
- public function addRole(\Acme\MyBundle\Entity\Role $roles)
- {
- $this->roles[] = $roles;
- return $this;
- }
- /**
- * Remove roles
- *
- * @param \Acme\MyBundle\Entity\Role $roles
- */
- public function removeRole(\Acme\MyBundle\Entity\Role $roles)
- {
- $this->roles->removeElement($roles);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement