/** * @param AuthenticatedUser $user * @return ConsentList|null */ public function findAllFor(AuthenticatedUser $user) { if (!$user->getAttributes()->containsAttributeDefinedBy($this->identifyingAttribute)) { $message = sprintf('Cannot get consent list for user: user does not have identifying attribute "%s"', $this->identifyingAttribute->getName()); $this->logger->error($message); return null; } $userIdentifier = $user->getAttributes()->getAttributeByDefinition($this->identifyingAttribute); $identifyingValues = $userIdentifier->getValue(); $identifyingValue = array_shift($identifyingValues); if (!is_string($identifyingValue)) { $message = sprintf('In order to get the consent list for a user, the identifying attribute must have a string value. "%s"' . 'given for identifying attribute "%s"', gettype($identifyingValue), $this->identifyingAttribute->getName()); $this->logger->error($message); return null; } return $this->consentRepository->findAllFor($identifyingValue); }
public function getAttributes() { return $this->authenticatedUser->getAttributes(); }