From 61613d0bf0b05ada206e3da3f05ba2703fc83f14 Mon Sep 17 00:00:00 2001 From: Yonel Ceruto Date: Mon, 3 Jun 2019 10:56:39 -0400 Subject: [PATCH] Add missing deprecations for PHP templating layer --- UPGRADE-4.4.md | 5 +++++ UPGRADE-5.0.md | 1 + src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md | 5 +++++ .../Bundle/FrameworkBundle/Controller/TemplateController.php | 4 ++++ .../Tests/Controller/TemplateControllerTest.php | 3 +++ .../TwigBundle/CacheWarmer/TemplateCacheCacheWarmer.php | 4 ++++ .../DependencyInjection/Compiler/ExtensionPass.php | 1 + .../Bundle/TwigBundle/Resources/config/templating.xml | 2 ++ src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml | 2 ++ .../HttpKernel/Fragment/HIncludeFragmentRenderer.php | 2 ++ 10 files changed, 29 insertions(+) diff --git a/UPGRADE-4.4.md b/UPGRADE-4.4.md index 0e044861bd..73d80523a2 100644 --- a/UPGRADE-4.4.md +++ b/UPGRADE-4.4.md @@ -31,6 +31,11 @@ Messenger * Deprecated passing a `ContainerInterface` instance as first argument of the `ConsumeMessagesCommand` constructor, pass a `RoutableMessageBus` instance instead. +FrameworkBundle +--------------- + + * Deprecated support for `templating` engine in `TemplateController`, use Twig instead + MonologBridge -------------- diff --git a/UPGRADE-5.0.md b/UPGRADE-5.0.md index 289910e8c2..1f1bd58ff5 100644 --- a/UPGRADE-5.0.md +++ b/UPGRADE-5.0.md @@ -219,6 +219,7 @@ FrameworkBundle * Removed support for legacy translations directories `src/Resources/translations/` and `src/Resources//translations/`, use `translations/` instead. * Support for the legacy directory structure in `translation:update` and `debug:translation` commands has been removed. * Removed the "Psr\SimpleCache\CacheInterface" / "cache.app.simple" service, use "Symfony\Contracts\Cache\CacheInterface" / "cache.app" instead. + * Removed support for `templating` engine in `TemplateController`, use Twig instead HttpFoundation -------------- diff --git a/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md b/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md index d32da9541a..4b1932e3a4 100644 --- a/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md +++ b/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md @@ -1,6 +1,11 @@ CHANGELOG ========= +4.4.0 +----- + + * Deprecated support for `templating` engine in `TemplateController`, use Twig instead + 4.3.0 ----- diff --git a/src/Symfony/Bundle/FrameworkBundle/Controller/TemplateController.php b/src/Symfony/Bundle/FrameworkBundle/Controller/TemplateController.php index 211c7ce6c8..8e359569f8 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Controller/TemplateController.php +++ b/src/Symfony/Bundle/FrameworkBundle/Controller/TemplateController.php @@ -29,6 +29,10 @@ class TemplateController public function __construct(Environment $twig = null, EngineInterface $templating = null) { + if (null !== $templating) { + @trigger_error(sprintf('Using a "%s" instance for "%s" is deprecated since version 4.4; use a \Twig\Environment instance instead.', EngineInterface::class, __CLASS__), E_USER_DEPRECATED); + } + $this->twig = $twig; $this->templating = $templating; } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/TemplateControllerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/TemplateControllerTest.php index a3abae0298..a19d0651bb 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/TemplateControllerTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/TemplateControllerTest.php @@ -31,6 +31,9 @@ class TemplateControllerTest extends TestCase $this->assertEquals('bar', $controller('mytemplate')->getContent()); } + /** + * @group legacy + */ public function testTemplating() { $templating = $this->getMockBuilder(EngineInterface::class)->getMock(); diff --git a/src/Symfony/Bundle/TwigBundle/CacheWarmer/TemplateCacheCacheWarmer.php b/src/Symfony/Bundle/TwigBundle/CacheWarmer/TemplateCacheCacheWarmer.php index f74b1c5325..4905bd3b1e 100644 --- a/src/Symfony/Bundle/TwigBundle/CacheWarmer/TemplateCacheCacheWarmer.php +++ b/src/Symfony/Bundle/TwigBundle/CacheWarmer/TemplateCacheCacheWarmer.php @@ -11,6 +11,8 @@ namespace Symfony\Bundle\TwigBundle\CacheWarmer; +@trigger_error('The '.TemplateCacheCacheWarmer::class.' class is deprecated since version 4.4 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED); + use Psr\Container\ContainerInterface; use Symfony\Bundle\FrameworkBundle\CacheWarmer\TemplateFinderInterface; use Symfony\Component\DependencyInjection\ServiceSubscriberInterface; @@ -26,6 +28,8 @@ use Twig\Error\Error; * as the Twig loader will need the cache generated by it. * * @author Fabien Potencier + * + * @deprecated since version 4.4, to be removed in 5.0; use Twig instead. */ class TemplateCacheCacheWarmer implements CacheWarmerInterface, ServiceSubscriberInterface { diff --git a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExtensionPass.php b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExtensionPass.php index 79a6ad9ae8..ba7e782378 100644 --- a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExtensionPass.php +++ b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExtensionPass.php @@ -105,6 +105,7 @@ class ExtensionPass implements CompilerPassInterface } else { $container->setAlias('twig.loader.filesystem', new Alias('twig.loader.native_filesystem', false)); $container->removeDefinition('templating.engine.twig'); + $container->removeDefinition('twig.cache_warmer'); } if ($container->has('assets.packages')) { diff --git a/src/Symfony/Bundle/TwigBundle/Resources/config/templating.xml b/src/Symfony/Bundle/TwigBundle/Resources/config/templating.xml index 1eba213f0e..6768328f46 100644 --- a/src/Symfony/Bundle/TwigBundle/Resources/config/templating.xml +++ b/src/Symfony/Bundle/TwigBundle/Resources/config/templating.xml @@ -17,6 +17,8 @@ + + The "%service_id%" service is deprecated since Symfony 4.4 and will be removed in 5.0. diff --git a/src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml b/src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml index 13121a2a18..684a688731 100644 --- a/src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml +++ b/src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml @@ -35,6 +35,8 @@ + + The "%service_id%" service is deprecated since Symfony 4.4 and will be removed in 5.0. diff --git a/src/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php b/src/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php index 9a700a9b11..08f7c167d5 100644 --- a/src/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php +++ b/src/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php @@ -52,6 +52,8 @@ class HIncludeFragmentRenderer extends RoutableFragmentRenderer * @param EngineInterface|Environment|null $templating An EngineInterface or an Environment instance * * @throws \InvalidArgumentException + * + * @internal */ public function setTemplating($templating) {