loadService($request, $key); } /** * @inheritDoc */ public function getAuthorizationService(ServerRequestInterface $request): AuthorizationServiceInterface { $key = 'Auth.Authorization.serviceLoader'; return $this->loadService($request, $key); } /** * @inheritDoc */ public function middleware(MiddlewareQueue $middlewareQueue): MiddlewareQueue { $loader = $this->getLoader('Users.middlewareQueueLoader'); return $loader($middlewareQueue, $this); } /** * Load a service defined in configuration $loaderKey * * @param \Psr\Http\Message\ServerRequestInterface $request The request. * @param string $loaderKey service loader key * @return mixed */ protected function loadService(ServerRequestInterface $request, $loaderKey) { $serviceLoader = $this->getLoader($loaderKey); return $serviceLoader($request); } /** * Get the loader callable * * @param string $loaderKey loader configuration key * @return callable */ protected function getLoader($loaderKey) { $serviceLoader = Configure::read($loaderKey); if (is_string($serviceLoader)) { $serviceLoader = new $serviceLoader(); } return $serviceLoader; } }