/** * @param ServerRequestInterface $request * @param ResponseInterface $response * @param callable|null $next * @return EmptyResponse * @throws \Exception */ public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next = null) { if ($this->isAdminAuthentication($request)) { $this->user->addRoles([Roles::ADMIN]); } return $next($request, $response); }