Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace Yanic\UsersBundle\Entity;
- use Symfony\Component\Security\Core\User\AdvancedUserInterface;
- use Symfony\Component\Security\Core\User\EquatableInterface;
- use Doctrine\Common\Collections\ArrayCollection;
- use Doctrine\ORM\Mapping as ORM;
- /**
- * Yanic\UsersBundle\Entity\Users
- *
- * @ORM\Table(name="users")
- * @ORM\Entity(repositoryClass="Yanic\UsersBundle\Entity\UsersRepository")
- */
- class Users implements AdvancedUserInterface, EquatableInterface
- {
- /**
- * @var integer $id
- *
- * @ORM\Column(name="id", type="integer", nullable=false)
- * @ORM\Id
- * @ORM\GeneratedValue(strategy="IDENTITY")
- */
- private $id;
- /**
- * @var string $username
- *
- * @ORM\Column(name="username", type="string", length=100, nullable=true)
- */
- private $username;
- /**
- * @var string $password
- *
- * @ORM\Column(name="password", type="string", length=200, nullable=false)
- */
- private $password;
- /**
- * @var string $salt
- *
- * @ORM\Column(name="salt", type="string", length=32, nullable=false)
- */
- private $salt;
- /**
- * @var string $email
- *
- * @ORM\Column(name="email", type="string", length=100, nullable=true)
- */
- private $email;
- /**
- * @var datetime $created
- *
- * @ORM\Column(name="created", type="datetime", nullable=false)
- */
- private $created;
- /**
- * @var datetime $modified
- *
- * @ORM\Column(name="modified", type="datetime", nullable=true)
- */
- private $modified;
- /**
- * @var boolean $isActive
- *
- * @ORM\Column(name="is_active", type="boolean", nullable=false)
- */
- private $isActive;
- /**
- * @var datetime $lastLogin
- *
- * @ORM\Column(name="last_login", type="datetime", nullable=true)
- */
- private $lastLogin;
- /**
- * @ORM\OneToOne(targetEntity="Yanic\UsersBundle\Entity\Users")
- */
- private $modifiedBy;
- /**
- * @var text $configs
- *
- * @ORM\Column(name="configs", type="text", nullable=false)
- */
- private $configs = '';
- /**
- * @ORM\ManyToMany(targetEntity="Roles", inversedBy="users")
- * @ORM\JoinTable(name="users_roles")
- */
- private $groups;
- public function __construct()
- {
- $logging = false;
- $this->isActive = true;
- $this->salt = md5(uniqid(null, true));
- $this->groups = new ArrayCollection();
- if( $logging && class_exists( 'FirePHP' ) ):
- $inspector = \FirePHP::to('page');
- $console = $inspector->console();
- $console->info('Users:__construct()');
- endif;
- }
- /**
- * @inheritDoc
- */
- public function eraseCredentials()
- {
- }
- /**
- * @inheritDoc
- */
- function isEqualTo(\Symfony\Component\Security\Core\User\UserInterface $user)
- {
- $inspector = \FirePHP::to('page');
- $console = $inspector->console();
- $console->info('Users::isEqualTo()');
- return $this->username === $user->getUsername();
- }
- /**
- * @inheritDoc
- */
- public function isAccountNonExpired()
- {
- $inspector = \FirePHP::to('page');
- $console = $inspector->console();
- $console->info( 'Users:' . __METHOD__ );
- return true;
- }
- /**
- * @inheritDoc
- */
- public function isAccountNonLocked()
- {
- $inspector = \FirePHP::to('page');
- $console = $inspector->console();
- $console->info( 'Users:' . __METHOD__ );
- return true;
- }
- /**
- * @inheritDoc
- */
- public function isCredentialsNonExpired()
- {
- $inspector = \FirePHP::to('page');
- $console = $inspector->console();
- $console->info( 'Users:' . __METHOD__ );
- return true;
- }
- /**
- * @inheritDoc
- */
- public function isEnabled()
- {
- $inspector = \FirePHP::to('page');
- $console = $inspector->console();
- $console->info( 'Users:' . __METHOD__ );
- return $this->isActive;
- }
- public function __toString()
- {
- $inspector = \FirePHP::to('page');
- $console = $inspector->console();
- $console->info('Users:__toString()');
- return $this->getUsername();
- }
- /**
- * Add groups
- *
- * @param Yanic\UsersBundle\Entity\Roles $groups
- */
- public function addGroup(Roles $groups)
- {
- $this->groups[] = $groups;
- }
- /**
- * Get groups
- *
- * @return Doctrine\Common\Collections\Collection
- */
- public function getGroups()
- {
- return $this->groups;
- }
- /**
- * Get id
- *
- * @return integer
- */
- public function getId()
- {
- return $this->id;
- }
- /**
- * Set username
- *
- * @param string $username
- */
- public function setUsername($username)
- {
- $this->username = $username;
- }
- /**
- * Get username
- *
- * @return string
- */
- public function getUsername()
- {
- $inspector = \FirePHP::to('page');
- $console = $inspector->console();
- $console->info('Users:getUsername()');
- return $this->username;
- }
- /**
- * Set password
- *
- * @param string $password
- */
- public function setPassword($password)
- {
- $this->password = $password;
- }
- /**
- * Get password
- *
- * @return string
- */
- public function getPassword()
- {
- $inspector = \FirePHP::to('page');
- $console = $inspector->console();
- $console->info('Password: ' . $this->password );
- return $this->password;
- }
- /**
- * Set salt
- *
- * @param string $salt
- */
- public function setSalt($salt)
- {
- $this->salt = $salt;
- }
- /**
- * Get salt
- *
- * @return string
- */
- public function getSalt()
- {
- return $this->salt;
- }
- /**
- * Set email
- *
- * @param string $email
- */
- public function setEmail($email)
- {
- $this->email = $email;
- }
- /**
- * Get email
- *
- * @return string
- */
- public function getEmail()
- {
- return $this->email;
- }
- /**
- * Set created
- *
- * @param datetime $created
- */
- public function setCreated($created)
- {
- $this->created = $created;
- }
- /**
- * Get created
- *
- * @return datetime
- */
- public function getCreated()
- {
- return $this->created;
- }
- /**
- * Set modified
- *
- * @param date $modified
- */
- public function setModified($modified)
- {
- $this->modified = $modified;
- }
- /**
- * Get modified
- *
- * @return date
- */
- public function getModified()
- {
- return $this->modified;
- }
- /**
- * Set isActive
- *
- * @param boolean $isActive
- */
- public function setIsActive($isActive)
- {
- $this->isActive = $isActive;
- }
- /**
- * Get isActive
- *
- * @return boolean
- */
- public function getIsActive()
- {
- return $this->isActive;
- }
- /**
- * Set lastLogin
- *
- * @param datetime $lastLogin
- */
- public function setLastLogin($lastLogin)
- {
- $this->lastLogin = $lastLogin;
- }
- /**
- * Get lastLogin
- *
- * @return datetime
- */
- public function getLastLogin()
- {
- return $this->lastLogin;
- }
- /**
- * Set modifiedBy
- *
- * @param integer $modifiedBy
- */
- public function setModifiedBy($modifiedBy)
- {
- $this->modifiedBy = $modifiedBy;
- }
- /**
- * Get modifiedBy
- *
- * @return integer
- */
- public function getModifiedBy()
- {
- return $this->modifiedBy;
- }
- /**
- * Set configs
- *
- * @param text $configs
- */
- public function setConfigs($configs)
- {
- $this->configs = $configs;
- }
- /**
- * Get configs
- *
- * @return text
- */
- public function getConfigs()
- {
- return $this->configs;
- }
- /**
- * @inheritDoc
- */
- public function getRoles()
- {
- return $this->groups->toArray();
- }
- }
Add Comment
Please, Sign In to add comment