public function createService(string $key, ServiceLocatorInterface $serviceLocator, array $extra = null): object
    {
        $config = $serviceLocator->getConfig();
        $config = $config[RouterInterface::class] ?? [];

        $router = new Router();
        foreach ($config['routes'] ?? [] as $name => $config) {
            $router->addRoute(
                $this->createRoute($serviceLocator, $config),
                $name
            );
        }

        return $router;
    }
public function createService(string $key, ServiceLocatorInterface $serviceLocator, array $extra = null): object
    {
        $config = $serviceLocator->getConfig();
        $config = $config[RouterInterface::class] ?? [];

        $router = new Router();
        foreach ($config['routes'] ?? [] as $name => $config) {
            $router->addRoute(
                $this->createRoute($serviceLocator, $config),
                $name
            );
        }

        return $router;
    }
public function createService ( string $ key , ServiceLocatorInterface $ serviceLocator , array $ extra = null ) : object { $ config = $ serviceLocator -> getConfig ( ) ; $ config = $ config [ RouterInterface :: class ] ?? [ ] ; $ router = new Router ( ) ; foreach ( $ config [ 'routes' ] ?? [ ] as $ name => $ config ) { $ router -> addRoute ( $ this -> createRoute ( $ serviceLocator , $ config ) , $ name ) ; } return $ router ; }
Create router.

@param string                  $key
@param ServiceLocatorInterface $serviceLocator
@param array|null              $extra
@return RouterInterface
@throws ServiceLocatorException
Create router .