public function register(Container $app) { $app['router.options'] = []; $app['router.loader_resolver'] = function () { $fileLocator = new FileLocator(); $loaderResolver = new LoaderResolver([new XmlFileLoader($fileLocator), new PhpFileLoader($fileLocator), new ClosureLoader()]); if (class_exists('Symfony\\Component\\Yaml\\Parser')) { $loaderResolver->addLoader(new YamlFileLoader($fileLocator)); } return $loaderResolver; }; $app['router'] = function (Application $app) { $router = new Router(new ClosureLoader(), function () use($app) { if (isset($app['router.resource'])) { $userLoader = new DelegatingLoader($app['router.loader_resolver']); $userRoutes = $userLoader->load($app['router.resource']); $app['routes']->addCollection($userRoutes); } $app->flush(); return $app['routes']; }, $app['router.options'] + ['debug' => isset($app['debug']) ? $app['debug'] : false, 'matcher_base_class' => 'Silex\\Provider\\Routing\\RedirectableUrlMatcher', 'matcher_class' => 'Silex\\Provider\\Routing\\RedirectableUrlMatcher'], $app['request_context'], $app['logger']); return $router; }; $app['request_matcher'] = function (Application $app) { return $app['router']; }; $app['url_generator'] = function (Application $app) { return $app['router']; }; }
public function register(Container $app) { $app['controllers_factory'] = function () use($app) { return new I18nControllerCollection($app['route_factory'], $app['locale'], $app['i18n_routing.locales']); }; $app['url_generator'] = function ($app) { $app->flush(); return new I18nUrlGenerator($app['routes'], $app['request_context']); }; $app['i18n_routing.locales'] = array('en'); }
public function register(Container $app) { $app['controllers_factory'] = function () use($app) { return new I18nControllerCollection($app['route_factory'], $app['locale'], $app['i18n_routing.locales'], $app['translator'], $app['i18n_routing.translation_domain'], $app['i18n_routing.allow_localized_default']); }; $app['url_generator'] = function ($app) { $app->flush(); return new I18nUrlGenerator($app['routes'], $app['request_context']); }; $app['i18n_routing.locales'] = array('en'); $app['i18n_routing.translation_domain'] = 'routes'; $app['i18n_routing.allow_localized_default'] = false; }