PPI\Framework\ServiceManager\Factory\RouterFactory::createService PHP Метод

createService() публичный Метод

public createService ( Zend\ServiceManager\ServiceLocatorInterface $serviceLocator ) : ChainRouter
$serviceLocator Zend\ServiceManager\ServiceLocatorInterface
Результат PPI\Framework\Router\ChainRouter
    public function createService(ServiceLocatorInterface $serviceLocator)
    {
        $request = $serviceLocator->get('Request');
        $requestContext = $serviceLocator->get('RouterRequestContext');
        $routerOptions = array();
        $logger = $serviceLocator->has('Logger') ? $serviceLocator->get('Logger') : null;
        $chainRouter = new ChainRouter($logger);
        if ($serviceLocator->has('RoutingCache')) {
            $chainRouter->setCache($serviceLocator->get('RoutingCache'));
        }
        $chainRouter->setContext($requestContext);
        $allModuleRoutes = $serviceLocator->get('ModuleDefaultListener')->getRoutes();
        // For each module, add a matching instance type to the chain router
        foreach ($allModuleRoutes as $moduleName => $moduleRoutingResponse) {
            switch (true) {
                // @todo - move this to a separate method()
                case $moduleRoutingResponse instanceof SymfonyRouteCollection:
                    $sfRouter = new SymfonyRouter($requestContext, $moduleRoutingResponse, $routerOptions, $logger);
                    $sfRouterWrapper = new SymfonyRouterWrapper($sfRouter);
                    $chainRouter->add($sfRouterWrapper);
                    break;
                    // @todo - move this to a separate method()
                // @todo - move this to a separate method()
                case $moduleRoutingResponse instanceof AuraRouter:
                    $auraRouterWrapper = new AuraRouterWrapper($moduleRoutingResponse);
                    $chainRouter->add($auraRouterWrapper);
                    break;
                    // @todo - move this to a separate method()
                // @todo - move this to a separate method()
                case $moduleRoutingResponse instanceof LaravelRouter:
                    $laravelRequest = new LaravelRequest();
                    $laravelUrlGenerator = new LaravelUrlGenerator($moduleRoutingResponse->getRoutes(), $laravelRequest);
                    $laravelRouterWrapper = new LaravelRouterWrapper($moduleRoutingResponse, $laravelRequest, $laravelUrlGenerator);
                    // @todo - solve this problem
                    //                    $laravelRouterWrapper->setModuleName($this->getName());
                    $chainRouter->add($laravelRouterWrapper);
                    break;
                case $moduleRoutingResponse instanceof FastRouteWrapper:
                    $chainRouter->add($moduleRoutingResponse);
                    break;
                default:
                    throw new \Exception('Unexpected routes value return from module: ' . $moduleName . '. found value of type: ' . gettype($moduleRoutingResponse));
            }
        }
        return $chainRouter;
    }
RouterFactory