groupCenters = new ArrayCollection(); } /** * @return string */ public function __toString() { return $this->getLabel(); } /** * Get id * * @return integer */ public function getId() { return $this->id; } /** * Set username * * @param string $name * @return Agent */ public function setUsername($name) { $this->username = $name; if (empty($this->getLabel())) { $this->setLabel($name); } return $this; } /** * @return string */ public function getUsername() { return $this->username; } /** */ public function eraseCredentials() {} /** * @return array */ public function getRoles() { return array('ROLE_USER'); } /** * @return null|string */ public function getSalt() { return $this->salt; } /** * @param $usernameCanonical * @return $this */ public function setUsernameCanonical($usernameCanonical) { $this->usernameCanonical = $usernameCanonical; return $this; } /** * @return string */ public function getUsernameCanonical() { return $this->usernameCanonical; } /** * @param $email * @return $this */ public function setEmail($email) { $this->email = $email; return $this; } /** * @return string */ public function getEmail() { return $this->email; } /** * @param $emailCanonical * @return $this */ public function setEmailCanonical($emailCanonical) { $this->emailCanonical = $emailCanonical; return $this; } /** * @return string */ public function getEmailCanonical() { return $this->emailCanonical; } /** * @param $password * @return $this */ function setPassword($password) { $this->password = $password; return $this; } /** * @return string */ public function getPassword() { return $this->password; } /** * @param $salt * @return $this */ function setSalt($salt) { $this->salt = $salt; return $this; } /** * @return bool */ public function isAccountNonExpired() { return true; } /** * @return bool */ public function isAccountNonLocked() { return $this->locked; } /** * @return bool */ public function isCredentialsNonExpired() { return true; } /** * @return bool */ public function isEnabled() { return $this->enabled; } /** * @param bool $enabled */ public function setEnabled($enabled) { $this->enabled = $enabled; return $this; } /** * @return GroupCenter */ public function getGroupCenters() { return $this->groupCenters; } /** * @param \Chill\MainBundle\Entity\GroupCenter $groupCenter * @return \Chill\MainBundle\Entity\User */ public function addGroupCenter(GroupCenter $groupCenter) { $this->groupCenters->add($groupCenter); return $this; } /** * @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(sprintf("The groupCenter could not be removed, " . "it seems not to be associated with the user. Aborting.")); } } /** * 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 = array(); foreach ($this->getGroupCenters() as $groupCenter) { if (in_array($groupCenter->getId(), $groupCentersIds)) { $context->buildViolation("The user has already those permissions") ->addViolation(); } else { $groupCentersIds[] = $groupCenter->getId(); } } } /** * Set attributes * * @param array $attributes * * @return Report */ public function setAttributes($attributes) { $this->attributes = $attributes; return $this; } /** * Get attributes * * @return array */ public function getAttributes() { if ($this->attributes === null) { $this->attributes = []; } return $this->attributes; } /** * @return string */ public function getLabel(): string { return $this->label; } /** * @param string $label * @return User */ public function setLabel(string $label): User { $this->label = $label; return $this; } /** * @return Center|null */ public function getMainCenter(): ?Center { return $this->mainCenter; } /** * @param Center|null $mainCenter * @return User */ public function setMainCenter(?Center $mainCenter): User { $this->mainCenter = $mainCenter; return $this; } /** * @return Scope|null */ public function getMainScope(): ?Scope { return $this->mainScope; } /** * @param Scope|null $mainScope * @return User */ public function setMainScope(?Scope $mainScope): User { $this->mainScope = $mainScope; return $this; } /** * @return UserJob|null */ public function getUserJob(): ?UserJob { return $this->userJob; } /** * @param UserJob|null $userJob * @return User */ public function setUserJob(?UserJob $userJob): User { $this->userJob = $userJob; return $this; } }