services = new ArrayCollection(); $this->events = new ArrayCollection(); $this->penaltys = new ArrayCollection(); $this->jobs = new ArrayCollection(); $this->userprojects = new ArrayCollection(); } public function getUsername(): ?string { return $this->username; } public function getSalt(): ?string { return $this->salt; } public function setPassword($password): self { if($password!=$this->password&&$password!=""&&!is_null($password)){ $this->salt = uniqid(mt_rand(), true); $hash = "{SSHA}" . base64_encode(pack("H*", sha1($password . $this->salt)) . $this->salt); $this->password = $hash; } return $this; } public function getPassword(): ?string { return $this->password; } public function getRoles(): ?array { return $this->roles; } public function eraseCredentials() { } public function serialize() { return serialize(array( $this->id, $this->username, $this->password, $this->salt, )); } public function unserialize($serialized) { list ( $this->id, $this->username, $this->password, $this->salt ) = unserialize($serialized, array('allowed_classes' => false)); } public function getDisplayname() { return $this->firstname." ".$this->lastname; } public function setId(int $id): self { $this->id = $id; return $this; } public function getId(): ?int { return $this->id; } public function setUsername(string $username): self { $this->username = $username; return $this; } public function setRoles(array $roles): self { $this->roles = $roles; return $this; } public function setSalt(string $salt): self { $this->salt = $salt; return $this; } public function getFirstname(): ?string { return $this->firstname; } public function setFirstname(?string $firstname): self { $this->firstname = $firstname; return $this; } public function getLastname(): ?string { return $this->lastname; } public function setLastname(?string $lastname): self { $this->lastname = $lastname; return $this; } public function getAvatar(): ?string { if($this->avatar) return $this->avatar; else return "noavatar.png"; } public function setAvatar(?string $avatar): self { $this->avatar = $avatar; return $this; } public function getEmail(): ?string { return $this->email; } public function setEmail(string $email): self { $this->email = $email; return $this; } public function getService(): ?Service { return $this->service; } public function setService(?Service $service): self { $this->service = $service; return $this; } /** * @return Collection|Event[] */ public function getEvents(): Collection { return $this->events; } public function addEvent(Event $event): self { if (!$this->events->contains($event)) { $this->events[] = $event; $event->setUser($this); } return $this; } public function removeEvent(Event $event): self { if ($this->events->contains($event)) { $this->events->removeElement($event); // set the owning side to null (unless already changed) if ($event->getUser() === $this) { $event->setUser(null); } } return $this; } /** * @return Collection|Penalty[] */ public function getPenaltys(): Collection { return $this->penaltys; } public function addPenalty(Penalty $penalty): self { if (!$this->penaltys->contains($penalty)) { $this->penaltys[] = $penalty; $penalty->setUser($this); } return $this; } public function removePenalty(Penalty $penalty): self { if ($this->penaltys->contains($penalty)) { $this->penaltys->removeElement($penalty); // set the owning side to null (unless already changed) if ($penalty->getUser() === $this) { $penalty->setUser(null); } } return $this; } public function getApikey(): ?string { return $this->apikey; } public function setApikey(?string $apikey): self { $this->apikey = $apikey; return $this; } /** * @return Collection|Job[] */ public function getJobs(): Collection { return $this->jobs; } public function addJob(Job $job): self { if (!$this->jobs->contains($job)) { $this->jobs[] = $job; } return $this; } public function removeJob(Job $job): self { if ($this->jobs->contains($job)) { $this->jobs->removeElement($job); } return $this; } /** * @return Collection|Userproject[] */ public function getUserprojects(): Collection { return $this->userprojects; } public function addUserproject(Userproject $userproject): self { if (!$this->userprojects->contains($userproject)) { $this->userprojects[] = $userproject; $userproject->setUser($this); } return $this; } public function removeUserproject(Userproject $userproject): self { if ($this->userprojects->contains($userproject)) { $this->userprojects->removeElement($userproject); // set the owning side to null (unless already changed) if ($userproject->getUser() === $this) { $userproject->setUser(null); } } return $this; } }