Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace XXX\AppBundle\Model\Entity;
- use XXX\AppBundle\Model\Entity\Server\Logging;
- use Doctrine\ORM\Mapping as ORM;
- use Symfony\Component\Security\Core\User\UserInterface;
- /**
- * User
- */
- class User implements UserInterface
- {
- /**
- * @var integer $id
- */
- protected $id;
- /**
- * @var string $username
- */
- protected $username;
- /**
- * @var string $email
- */
- protected $email;
- /**
- * @var string $password
- */
- protected $password;
- /**
- * @var array $roles
- */
- protected $roles = array();
- /**
- * @var \Doctrine\Common\Collections\Collection $logEvents
- */
- protected $logEvents;
- /**
- * @return int
- */
- public function getId()
- {
- return $this->id;
- }
- /**
- * {@inheritdoc}
- */
- public function getUsername()
- {
- return $this->username;
- }
- /**
- * @param string $username
- * @return $this
- */
- public function setUsername($username)
- {
- $this->username = $username;
- return $this;
- }
- /**
- * @return string
- */
- public function getEmail()
- {
- return $this->email;
- }
- /**
- * @param string $email
- * @return $this
- */
- public function setEmail($email)
- {
- $this->email = $email;
- return $this;
- }
- /**
- * {@inheritdoc}
- */
- public function getPassword()
- {
- return $this->password;
- }
- /**
- * @param string $password
- * @return $this
- */
- public function setPassword($password)
- {
- $this->password = $password;
- return $this;
- }
- /**
- * Returns the roles or permissions granted to the user for security.
- */
- public function getRoles()
- {
- $roles = $this->roles;
- // guarantees that a user always has at least one role for security
- if (empty($roles)) {
- $roles[] = 'ROLE_USER';
- }
- return array_unique($roles);
- }
- public function setRoles(array $roles)
- {
- $this->roles = $roles;
- }
- /**
- * Returns the salt that was originally used to encode the password.
- */
- public function getSalt()
- {
- // See "Do you need to use a Salt?" at http://symfony.com/doc/current/cookbook/security/entity_provider.html
- // we're using bcrypt in security.yml to encode the password, so
- // the salt value is built-in and you don't have to generate one
- return;
- }
- /**
- * Removes sensitive data from the user.
- */
- public function eraseCredentials()
- {
- $this->password = null;
- $this->email = null;
- }
- /**
- * Appends an entry to administration log
- *
- * @param \XXX\AppBundle\Model\Entity\Server\Logging $logEvent
- * @return $this
- */
- public function appendLog(Server\Logging $logEvent)
- {
- if (!$this->logEvents->contains($logEvent))
- {
- $this->logEvents->add($logEvent);
- }
- return $this;
- }
- /**
- * Remove a log entry from the history
- *
- * @param \XXX\AppBundle\Model\Entity\Server\Logging $logEvent
- * @return $this
- */
- public function clearLogEntry(Server\Logging $logEvent)
- {
- $this->logEvents->removeElement($logEvent);
- return $this;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement