groupCenters = new ArrayCollection(); } public function __toString(): string { return $this->getLabel(); } public function addGroupCenter(GroupCenter $groupCenter): self { $this->groupCenters->add($groupCenter); return $this; } // empty function... remove? public function eraseCredentials() { } public function getAttributes(): ?array { if (null === $this->attributes) { $this->attributes = []; } return $this->attributes; } public function getCurrentLocation(): ?Location { return $this->currentLocation; } public function getEmail(): ?string { return $this->email; } public function getEmailCanonical(): ?string { return $this->emailCanonical; } /** * @return GroupCenter */ public function getGroupCenters() { return $this->groupCenters; } public function getId(): ?int { return $this->id; } public function getLabel(): string { return $this->label; } public function getMainCenter(): ?Center { return $this->mainCenter; } public function getMainLocation(): ?Location { return $this->mainLocation; } public function getMainScope(): ?Scope { return $this->mainScope; } public function getPassword(): string { return $this->password; } public function getRoles(): array { return array_unique($this->roles); } public function getSalt(): ?string { return $this->salt; } public function getUserJob(): ?UserJob { return $this->userJob; } public function getUsername(): string { return $this->username; } public function getUsernameCanonical(): ?string { return $this->usernameCanonical; } public function isAccountNonExpired(): bool { return true; } public function isAccountNonLocked(): bool { return $this->locked; } public function isCredentialsNonExpired(): bool { return true; } public function isEnabled(): bool { return $this->enabled; } /** * This function check that groupCenter are present only once. The validator * use this function to avoid a user to be associated to the same groupCenter * more than once. */ public function isGroupCenterPresentOnce(ExecutionContextInterface $context) { $groupCentersIds = []; foreach ($this->getGroupCenters() as $groupCenter) { if (in_array($groupCenter->getId(), $groupCentersIds, true)) { $context->buildViolation('The user has already those permissions') ->addViolation(); } else { $groupCentersIds[] = $groupCenter->getId(); } } } /** * @param \Chill\MainBundle\Entity\GroupCenter $groupCenter * * @throws RuntimeException if the groupCenter is not in the collection */ public function removeGroupCenter(GroupCenter $groupCenter) { if ($this->groupCenters->removeElement($groupCenter) === false) { throw new RuntimeException('The groupCenter could not be removed, ' . 'it seems not to be associated with the user. Aborting.'); } } /** * Set attributes. * * @param array $attributes * * @return Report */ public function setAttributes($attributes) { $this->attributes = $attributes; return $this; } public function setCurrentLocation(?Location $currentLocation): self { $this->currentLocation = $currentLocation; return $this; } public function setEmail($email): self { $this->email = $email; return $this; } public function setEmailCanonical($emailCanonical): self { $this->emailCanonical = $emailCanonical; return $this; } public function setEnabled(bool $enabled): self { $this->enabled = $enabled; return $this; } public function setLabel(string $label): self { $this->label = $label; return $this; } public function setMainCenter(?Center $mainCenter): self { $this->mainCenter = $mainCenter; return $this; } public function setMainLocation(?Location $mainLocation): self { $this->mainLocation = $mainLocation; return $this; } public function setMainScope(?Scope $mainScope): self { $this->mainScope = $mainScope; return $this; } public function setPassword($password): self { $this->password = $password; return $this; } public function setRoles($roles): self { $this->roles = $roles; return $this; } public function setSalt($salt): self { $this->salt = $salt; return $this; } public function setUserJob(?UserJob $userJob): self { $this->userJob = $userJob; return $this; } /** * Set username. * * @param string $name * * @return Agent */ public function setUsername($name) { $this->username = $name; if (empty($this->getLabel())) { $this->setLabel($name); } return $this; } public function setUsernameCanonical($usernameCanonical): self { $this->usernameCanonical = $usernameCanonical; return $this; } }