-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
minor #37280 [Routing] Move configuration to PHP (phamuyentri)
This PR was squashed before being merged into the 5.2-dev branch. Discussion ---------- [Routing] Move configuration to PHP | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | [#37186](#37186) | License | MIT Moving routing configurations in FrameworkBundle to PHP Commits ------- 268edd8 [Routing] Move configuration to PHP
- Loading branch information
Showing
3 changed files
with
179 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
176 changes: 176 additions & 0 deletions
176
src/Symfony/Bundle/FrameworkBundle/Resources/config/routing.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,176 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\DependencyInjection\Loader\Configurator; | ||
|
||
use Psr\Container\ContainerInterface; | ||
use Symfony\Bundle\FrameworkBundle\CacheWarmer\RouterCacheWarmer; | ||
use Symfony\Bundle\FrameworkBundle\Controller\RedirectController; | ||
use Symfony\Bundle\FrameworkBundle\Controller\TemplateController; | ||
use Symfony\Bundle\FrameworkBundle\Routing\DelegatingLoader; | ||
use Symfony\Bundle\FrameworkBundle\Routing\RedirectableCompiledUrlMatcher; | ||
use Symfony\Bundle\FrameworkBundle\Routing\Router; | ||
use Symfony\Component\Config\Loader\LoaderResolver; | ||
use Symfony\Component\HttpKernel\EventListener\RouterListener; | ||
use Symfony\Component\Routing\Generator\CompiledUrlGenerator; | ||
use Symfony\Component\Routing\Generator\Dumper\CompiledUrlGeneratorDumper; | ||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface; | ||
use Symfony\Component\Routing\Loader\ContainerLoader; | ||
use Symfony\Component\Routing\Loader\DirectoryLoader; | ||
use Symfony\Component\Routing\Loader\GlobFileLoader; | ||
use Symfony\Component\Routing\Loader\PhpFileLoader; | ||
use Symfony\Component\Routing\Loader\XmlFileLoader; | ||
use Symfony\Component\Routing\Loader\YamlFileLoader; | ||
use Symfony\Component\Routing\Matcher\Dumper\CompiledUrlMatcherDumper; | ||
use Symfony\Component\Routing\Matcher\ExpressionLanguageProvider; | ||
use Symfony\Component\Routing\Matcher\UrlMatcherInterface; | ||
use Symfony\Component\Routing\RequestContext; | ||
use Symfony\Component\Routing\RequestContextAwareInterface; | ||
use Symfony\Component\Routing\RouterInterface; | ||
|
||
return static function (ContainerConfigurator $container) { | ||
$container->parameters() | ||
->set('router.request_context.host', 'localhost') | ||
->set('router.request_context.scheme', 'http') | ||
->set('router.request_context.base_url', '') | ||
; | ||
|
||
$container->services() | ||
->set('routing.resolver', LoaderResolver::class) | ||
|
||
->set('routing.loader.xml', XmlFileLoader::class) | ||
->args([ | ||
service('file_locator'), | ||
]) | ||
->tag('routing.loader') | ||
|
||
->set('routing.loader.yml', YamlFileLoader::class) | ||
->args([ | ||
service('file_locator'), | ||
]) | ||
->tag('routing.loader') | ||
|
||
->set('routing.loader.php', PhpFileLoader::class) | ||
->args([ | ||
service('file_locator'), | ||
]) | ||
->tag('routing.loader') | ||
|
||
->set('routing.loader.glob', GlobFileLoader::class) | ||
->args([ | ||
service('file_locator'), | ||
]) | ||
->tag('routing.loader') | ||
|
||
->set('routing.loader.directory', DirectoryLoader::class) | ||
->args([ | ||
service('file_locator'), | ||
]) | ||
->tag('routing.loader') | ||
|
||
->set('routing.loader.container', ContainerLoader::class) | ||
->args([ | ||
tagged_locator('routing.route_loader'), | ||
]) | ||
->tag('routing.loader') | ||
|
||
->set('routing.loader', DelegatingLoader::class) | ||
->public() | ||
->args([ | ||
service('routing.resolver'), | ||
[], // Default options | ||
[], // Default requirements | ||
]) | ||
|
||
->set('router.default', Router::class) | ||
->args([ | ||
service(ContainerInterface::class), | ||
param('router.resource'), | ||
[ | ||
'cache_dir' => param('kernel.cache_dir'), | ||
'debug' => param('kernel.debug'), | ||
'generator_class' => CompiledUrlGenerator::class, | ||
'generator_dumper_class' => CompiledUrlGeneratorDumper::class, | ||
'matcher_class' => RedirectableCompiledUrlMatcher::class, | ||
'matcher_dumper_class' => CompiledUrlMatcherDumper::class, | ||
], | ||
service('router.request_context')->ignoreOnInvalid(), | ||
service('parameter_bag')->ignoreOnInvalid(), | ||
service('logger')->ignoreOnInvalid(), | ||
param('kernel.default_locale'), | ||
]) | ||
->call('setConfigCacheFactory', [ | ||
service('config_cache_factory'), | ||
]) | ||
->tag('monolog.logger', ['channel' => 'router']) | ||
->tag('container.service_subscriber', ['id' => 'routing.loader']) | ||
->alias('router', 'router.default') | ||
->public() | ||
->alias(RouterInterface::class, 'router') | ||
->alias(UrlGeneratorInterface::class, 'router') | ||
->alias(UrlMatcherInterface::class, 'router') | ||
->alias(RequestContextAwareInterface::class, 'router') | ||
|
||
->set('router.request_context', RequestContext::class) | ||
->factory([RequestContext::class, 'fromUri']) | ||
->args([ | ||
param('router.request_context.base_url'), | ||
param('router.request_context.host'), | ||
param('router.request_context.scheme'), | ||
param('request_listener.http_port'), | ||
param('request_listener.https_port'), | ||
]) | ||
->call('setParameter', [ | ||
'_functions', | ||
service('router.expression_language_provider')->ignoreOnInvalid(), | ||
]) | ||
->alias(RequestContext::class, 'router.request_context') | ||
|
||
->set('router.expression_language_provider', ExpressionLanguageProvider::class) | ||
->args([ | ||
tagged_locator('routing.expression_language_function', 'function'), | ||
]) | ||
->tag('routing.expression_language_provider') | ||
|
||
->set('router.cache_warmer', RouterCacheWarmer::class) | ||
->args([service(ContainerInterface::class)]) | ||
->tag('container.service_subscriber', ['id' => 'router']) | ||
->tag('kernel.cache_warmer') | ||
|
||
->set('router_listener', RouterListener::class) | ||
->args([ | ||
service('router'), | ||
service('request_stack'), | ||
service('router.request_context')->ignoreOnInvalid(), | ||
service('logger')->ignoreOnInvalid(), | ||
param('kernel.project_dir'), | ||
param('kernel.debug'), | ||
]) | ||
->tag('kernel.event_subscriber') | ||
->tag('monolog.logger', ['channel' => 'request']) | ||
|
||
->set(RedirectController::class) | ||
->public() | ||
->args([ | ||
service('router'), | ||
inline_service('int') | ||
->factory([service('router.request_context'), 'getHttpPort']), | ||
inline_service('int') | ||
->factory([service('router.request_context'), 'getHttpsPort']), | ||
]) | ||
|
||
->set(TemplateController::class) | ||
->args([ | ||
service('twig')->ignoreOnInvalid(), | ||
]) | ||
->public() | ||
; | ||
}; |
128 changes: 0 additions & 128 deletions
128
src/Symfony/Bundle/FrameworkBundle/Resources/config/routing.xml
This file was deleted.
Oops, something went wrong.