isActive = true; $this->salt = md5(uniqid(null, true)); $this->entries = new ArrayCollection(); $this->tags = new ArrayCollection(); } /** * @ORM\PrePersist * @ORM\PreUpdate */ public function timestamps() { if (is_null($this->createdAt)) { $this->createdAt = new \DateTime(); } $this->updatedAt = new \DateTime(); } /** * 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; } /** * @inheritDoc */ public function getSalt() { return $this->salt; } /** * @inheritDoc */ public function getRoles() { return array('ROLE_USER'); } /** * Set password. * * @param string $password * * @return User */ public function setPassword($password) { if (!$password && 0 === strlen($password)) { return; } $this->password = sha1($password.$this->getUsername().$this->getSalt()); return $this; } /** * Get password. * * @return string */ public function getPassword() { return $this->password; } /** * Set name. * * @param string $name * * @return User */ public function setName($name) { $this->name = $name; return $this; } /** * Get name. * * @return string */ public function getName() { return $this->name; } /** * 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; } /** * @return string */ public function getCreatedAt() { return $this->createdAt; } /** * @return string */ public function getUpdatedAt() { return $this->updatedAt; } /** * @param Entry $entry * * @return User */ public function addEntry(Entry $entry) { $this->entries[] = $entry; return $this; } /** * @return ArrayCollection */ public function getEntries() { return $this->entries; } /** * @param Entry $entry * * @return User */ public function addTag(Tag $tag) { $this->tags[] = $tag; return $this; } /** * @return ArrayCollection */ public function getTags() { return $this->tags; } /** * @inheritDoc */ public function eraseCredentials() { } /** * @see \Serializable::serialize() */ public function serialize() { return serialize(array( $this->id, )); } /** * @see \Serializable::unserialize() */ public function unserialize($serialized) { list( $this->id) = unserialize($serialized); } public function isEqualTo(UserInterface $user) { return $this->username === $user->getUsername(); } public function isAccountNonExpired() { return true; } public function isAccountNonLocked() { return true; } public function isCredentialsNonExpired() { return true; } public function isEnabled() { return $this->isActive; } /** * Set config. * * @param \Wallabag\CoreBundle\Entity\Config $config * * @return User */ public function setConfig(\Wallabag\CoreBundle\Entity\Config $config = null) { $this->config = $config; return $this; } /** * Get config. * * @return \Wallabag\CoreBundle\Entity\Config */ public function getConfig() { return $this->config; } /** * Set confirmationToken. * * @param string $confirmationToken * * @return User */ public function setConfirmationToken($confirmationToken) { $this->confirmationToken = $confirmationToken; return $this; } /** * Get confirmationToken. * * @return string */ public function getConfirmationToken() { return $this->confirmationToken; } /** * Set passwordRequestedAt. * * @param \DateTime $passwordRequestedAt * * @return User */ public function setPasswordRequestedAt($passwordRequestedAt) { $this->passwordRequestedAt = $passwordRequestedAt; return $this; } /** * Get passwordRequestedAt. * * @return \DateTime */ public function getPasswordRequestedAt() { return $this->passwordRequestedAt; } }