function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next) { $this->redirection->setRequest($request); $base = $this->settings->urlPrefix(); $base = $base ? "{$base}..." : '*'; return $this->router->set([$base => [when($this->settings->requireAuthentication(), AuthenticationMiddleware::class), '.' => page('platform/home.html'), 'settings...' => [when($this->settings->enableUsersManagement(), ['users-management...' => ['users' => factory(function (UsersPage $page) { // This is done here just to show off this possibility $page->templateUrl = 'platform/users/users.html'; return $page; }), 'users/@id' => UserPage::class, 'profile' => factory(function (UserPage $page) { $page->editingSelf = true; return $page; })]])]]])->__invoke($request, $response, $next); }