diff --git a/UPGRADE-3.3.md b/UPGRADE-3.3.md index 77fb28f53d..8fbfebc6bf 100644 --- a/UPGRADE-3.3.md +++ b/UPGRADE-3.3.md @@ -162,6 +162,10 @@ FrameworkBundle has been deprecated and will be removed in 4.0. Use the `Symfony\Component\HttpKernel\DependencyInjection\ControllerArgumentValueResolverPass` class instead. + * The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\RoutingResolverPass` + class has been deprecated and will be removed in 4.0. Use the + `Symfony\Component\Routing\DependencyInjection\RoutingResolverPass` class instead. + HttpKernel ----------- diff --git a/UPGRADE-4.0.md b/UPGRADE-4.0.md index 1914bfae19..d42a6d7dc8 100644 --- a/UPGRADE-4.0.md +++ b/UPGRADE-4.0.md @@ -221,6 +221,10 @@ FrameworkBundle has been removed. Use the `Symfony\Component\HttpKernel\DependencyInjection\ControllerArgumentValueResolverPass` class instead. + * The `Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\RoutingResolverPass` + class has been removed. Use the + `Symfony\Component\Routing\DependencyInjection\RoutingResolverPass` class instead. + HttpFoundation --------------- diff --git a/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md b/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md index 588e84dcdf..99f55dbd9a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md +++ b/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md @@ -27,8 +27,9 @@ CHANGELOG `render()`, `renderView()` and `stream()` methods can only use Twig (using the Templating component is not supported). The `json()` method requires the Serializer component (use `Symfony\Component\HttpFoundation\JsonResponse` directly if you do not want to use the Serializer). - * Deprecated `ControllerArgumentValueResolverPass`. Use + * Deprecated `ControllerArgumentValueResolverPass`. Use `Symfony\Component\HttpKernel\DependencyInjection\ControllerArgumentValueResolverPass` instead + * Deprecated `RoutingResolverPass`, use `Symfony\Component\Routing\DependencyInjection\RoutingResolverPass` instead 3.2.0 ----- diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/RoutingResolverPass.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/RoutingResolverPass.php index 6ff7c124cd..bac782115b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/RoutingResolverPass.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/RoutingResolverPass.php @@ -11,27 +11,17 @@ namespace Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler; -use Symfony\Component\DependencyInjection\Reference; -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; +use Symfony\Component\Routing\DependencyInjection\RoutingResolverPass as BaseRoutingResolverPass; + +@trigger_error(sprintf('The %s class is deprecated since version 3.3 and will be removed in 4.0. Use %s instead.', RoutingResolverPass::class, BaseRoutingResolverPass::class), E_USER_DEPRECATED); /** * Adds tagged routing.loader services to routing.resolver service. * * @author Fabien Potencier + * + * @deprecated since version 3.3, to be removed in 4.0. Use {@link BaseRoutingResolverPass} */ -class RoutingResolverPass implements CompilerPassInterface +class RoutingResolverPass extends BaseRoutingResolverPass { - public function process(ContainerBuilder $container) - { - if (false === $container->hasDefinition('routing.resolver')) { - return; - } - - $definition = $container->getDefinition('routing.resolver'); - - foreach ($container->findTaggedServiceIds('routing.loader') as $id => $attributes) { - $definition->addMethodCall('addLoader', array(new Reference($id))); - } - } } diff --git a/src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php b/src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php index a3c512eff5..fa4951e2da 100644 --- a/src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php +++ b/src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php @@ -20,7 +20,6 @@ use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\CachePoolPass; use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\CachePoolClearerPass; use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\DataCollectorTranslatorPass; use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TemplatingPass; -use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\RoutingResolverPass; use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ProfilerPass; use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TranslatorPass; use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\LoggingTranslatorPass; @@ -37,6 +36,7 @@ use Symfony\Component\Config\DependencyInjection\ConfigCachePass; use Symfony\Component\Console\DependencyInjection\AddConsoleCommandPass; use Symfony\Component\HttpKernel\DependencyInjection\ControllerArgumentValueResolverPass; use Symfony\Component\PropertyInfo\DependencyInjection\PropertyInfoPass; +use Symfony\Component\Routing\DependencyInjection\RoutingResolverPass; use Symfony\Component\Serializer\DependencyInjection\SerializerPass; use Symfony\Component\Debug\ErrorHandler; use Symfony\Component\DependencyInjection\ContainerBuilder; diff --git a/src/Symfony/Bundle/FrameworkBundle/composer.json b/src/Symfony/Bundle/FrameworkBundle/composer.json index feaa98826f..178adebf01 100644 --- a/src/Symfony/Bundle/FrameworkBundle/composer.json +++ b/src/Symfony/Bundle/FrameworkBundle/composer.json @@ -27,7 +27,7 @@ "symfony/polyfill-mbstring": "~1.0", "symfony/filesystem": "~2.8|~3.0", "symfony/finder": "~2.8|~3.0", - "symfony/routing": "~3.1.10|^3.2.3", + "symfony/routing": "~3.3", "symfony/security-core": "~2.8|~3.0", "symfony/security-csrf": "~2.8|~3.0", "symfony/stopwatch": "~2.8|~3.0", diff --git a/src/Symfony/Component/Routing/DependencyInjection/RoutingResolverPass.php b/src/Symfony/Component/Routing/DependencyInjection/RoutingResolverPass.php new file mode 100644 index 0000000000..5a31471f6b --- /dev/null +++ b/src/Symfony/Component/Routing/DependencyInjection/RoutingResolverPass.php @@ -0,0 +1,46 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Routing\DependencyInjection; + +use Symfony\Component\DependencyInjection\Reference; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; + +/** + * Adds tagged routing.loader services to routing.resolver service. + * + * @author Fabien Potencier + */ +class RoutingResolverPass implements CompilerPassInterface +{ + private $resolverServiceId; + private $loaderTag; + + public function __construct($resolverServiceId = 'routing.resolver', $loaderTag = 'routing.loader') + { + $this->resolverServiceId = $resolverServiceId; + $this->loaderTag = $loaderTag; + } + + public function process(ContainerBuilder $container) + { + if (false === $container->hasDefinition($this->resolverServiceId)) { + return; + } + + $definition = $container->getDefinition($this->resolverServiceId); + + foreach ($container->findTaggedServiceIds($this->loaderTag) as $id => $attributes) { + $definition->addMethodCall('addLoader', array(new Reference($id))); + } + } +} diff --git a/src/Symfony/Component/Routing/Tests/DependencyInjection/RoutingResolverPassTest.php b/src/Symfony/Component/Routing/Tests/DependencyInjection/RoutingResolverPassTest.php new file mode 100644 index 0000000000..97a34c969c --- /dev/null +++ b/src/Symfony/Component/Routing/Tests/DependencyInjection/RoutingResolverPassTest.php @@ -0,0 +1,36 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Routing\Tests\DependencyInjection; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\Config\Loader\LoaderResolver; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Reference; +use Symfony\Component\Routing\DependencyInjection\RoutingResolverPass; + +class RoutingResolverPassTest extends TestCase +{ + public function testProcess() + { + $container = new ContainerBuilder(); + $container->register('routing.resolver', LoaderResolver::class); + $container->register('loader1')->addTag('routing.loader'); + $container->register('loader2')->addTag('routing.loader'); + + (new RoutingResolverPass())->process($container); + + $this->assertEquals( + array(array('addLoader', array(new Reference('loader1'))), array('addLoader', array(new Reference('loader2')))), + $container->getDefinition('routing.resolver')->getMethodCalls() + ); + } +} diff --git a/src/Symfony/Component/Routing/composer.json b/src/Symfony/Component/Routing/composer.json index 0a53da0893..11418c7164 100644 --- a/src/Symfony/Component/Routing/composer.json +++ b/src/Symfony/Component/Routing/composer.json @@ -23,6 +23,7 @@ "symfony/http-foundation": "~2.8|~3.0", "symfony/yaml": "~2.8|~3.0", "symfony/expression-language": "~2.8|~3.0", + "symfony/dependency-injection": "~2.8|~3.0", "doctrine/annotations": "~1.0", "doctrine/common": "~2.2", "psr/log": "~1.0"