isActive = true; $this->salt = md5(uniqid(null, true)); $this->entries = 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 integer */ 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; } /** * @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; } }