From 224c891e10f53757e4669f674d160edccbb90790 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Fri, 23 Dec 2016 15:53:44 +0100 Subject: [PATCH 1/2] [FrameworkBundle] Deprecate the Templating component integration --- .../Bridge/Twig/Tests/TwigEngineTest.php | 3 ++ src/Symfony/Bridge/Twig/TwigEngine.php | 4 +++ .../CacheWarmer/TemplateFinder.php | 4 +++ .../CacheWarmer/TemplateFinderInterface.php | 4 +++ .../CacheWarmer/TemplatePathsCacheWarmer.php | 4 +++ .../Controller/ControllerTrait.php | 6 ++++ .../Compiler/TemplatingPass.php | 8 +++++ .../FrameworkExtension.php | 2 ++ .../Resources/config/templating.xml | 15 +++++++++ .../Resources/config/templating_debug.xml | 2 ++ .../Resources/config/templating_php.xml | 28 +++++++++++++++++ .../Templating/DelegatingEngine.php | 4 +++ .../Templating/EngineInterface.php | 4 +++ .../Templating/GlobalVariables.php | 4 +++ .../Templating/Helper/ActionsHelper.php | 4 +++ .../Templating/Helper/AssetsHelper.php | 4 +++ .../Templating/Helper/CodeHelper.php | 6 +++- .../Templating/Helper/FormHelper.php | 4 +++ .../Templating/Helper/RequestHelper.php | 4 +++ .../Templating/Helper/RouterHelper.php | 4 +++ .../Templating/Helper/SessionHelper.php | 4 +++ .../Templating/Helper/StopwatchHelper.php | 4 +++ .../Templating/Helper/TranslatorHelper.php | 4 +++ .../Templating/Loader/FilesystemLoader.php | 4 +++ .../Templating/Loader/TemplateLocator.php | 4 +++ .../FrameworkBundle/Templating/PhpEngine.php | 4 +++ .../Templating/TemplateFilenameParser.php | 4 +++ .../Templating/TemplateNameParser.php | 4 +++ .../Templating/TemplateReference.php | 4 +++ .../Templating/TimedPhpEngine.php | 4 +++ .../Tests/CacheWarmer/TemplateFinderTest.php | 3 ++ .../TemplatePathsCacheWarmerTest.php | 3 ++ .../Tests/Controller/ControllerTraitTest.php | 9 ++++++ .../DependencyInjection/Fixtures/php/full.php | 9 ------ .../Fixtures/php/templating.php | 14 +++++++++ .../DependencyInjection/Fixtures/xml/full.xml | 10 ------ .../Fixtures/xml/templating.xml | 22 +++++++++++++ .../DependencyInjection/Fixtures/yml/full.yml | 7 ----- .../Fixtures/yml/templating.yml | 9 ++++++ .../FrameworkExtensionTest.php | 16 ++++++++-- .../Tests/Functional/AutowiringTypesTest.php | 5 ++- .../AutowiringTypes/AutowiredServices.php | 18 +---------- .../AutowiringTypes/TemplatingServices.php | 31 +++++++++++++++++++ .../Controller/FragmentController.php | 5 +-- .../Tests/Functional/FragmentTest.php | 13 ++++++-- .../Functional/app/AutowiringTypes/config.yml | 3 -- .../app/AutowiringTypes/templating.yml | 12 +++++++ .../Functional/app/ContainerDump/config.yml | 3 -- .../Tests/Functional/app/Fragment/bundles.php | 2 ++ .../Tests/Functional/app/Fragment/config.yml | 6 ++-- .../Functional/app/Fragment/services.yml | 6 ++++ .../app/Resources/views/fragment.html.php | 14 --------- .../app/templates/fragment.html.twig | 7 +++++ .../Tests/Templating/DelegatingEngineTest.php | 3 ++ .../Tests/Templating/GlobalVariablesTest.php | 3 ++ .../Templating/Helper/AssetsHelperTest.php | 3 ++ .../Helper/FormHelperDivLayoutTest.php | 3 ++ .../Helper/FormHelperTableLayoutTest.php | 3 ++ .../Templating/Helper/RequestHelperTest.php | 3 ++ .../Templating/Helper/SessionHelperTest.php | 3 ++ .../Templating/Helper/StopwatchHelperTest.php | 3 ++ .../Templating/Loader/TemplateLocatorTest.php | 3 ++ .../Tests/Templating/PhpEngineTest.php | 3 ++ .../Templating/TemplateFilenameParserTest.php | 3 ++ .../Templating/TemplateNameParserTest.php | 3 ++ .../Templating/TemplateReferenceTest.php | 3 ++ .../Tests/Templating/TemplateTest.php | 3 ++ .../Tests/Templating/TimedPhpEngineTest.php | 3 ++ .../Bundle/FrameworkBundle/composer.json | 1 + .../Tests/Functional/CacheWarmingTest.php | 3 ++ src/Symfony/Bundle/TwigBundle/TwigEngine.php | 4 +++ 71 files changed, 365 insertions(+), 73 deletions(-) create mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/templating.php create mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/templating.xml create mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/templating.yml create mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/AutowiringTypes/TemplatingServices.php create mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AutowiringTypes/templating.yml create mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Fragment/services.yml delete mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Resources/views/fragment.html.php create mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/templates/fragment.html.twig diff --git a/src/Symfony/Bridge/Twig/Tests/TwigEngineTest.php b/src/Symfony/Bridge/Twig/Tests/TwigEngineTest.php index ab932eebc3dcf..89eba52167945 100644 --- a/src/Symfony/Bridge/Twig/Tests/TwigEngineTest.php +++ b/src/Symfony/Bridge/Twig/Tests/TwigEngineTest.php @@ -17,6 +17,9 @@ use Twig\Environment; use Twig\Loader\ArrayLoader; +/** + * @group legacy + */ class TwigEngineTest extends TestCase { public function testExistsWithTemplateInstances() diff --git a/src/Symfony/Bridge/Twig/TwigEngine.php b/src/Symfony/Bridge/Twig/TwigEngine.php index 4789f3f4d60b0..266d824bb4e6f 100644 --- a/src/Symfony/Bridge/Twig/TwigEngine.php +++ b/src/Symfony/Bridge/Twig/TwigEngine.php @@ -11,6 +11,8 @@ namespace Symfony\Bridge\Twig; +@trigger_error('The '.TwigEngine::class.' class is deprecated since version 4.3 and will be removed in 5.0; use \Twig\Environment instead.', E_USER_DEPRECATED); + use Symfony\Component\Templating\EngineInterface; use Symfony\Component\Templating\StreamingEngineInterface; use Symfony\Component\Templating\TemplateNameParserInterface; @@ -25,6 +27,8 @@ * This engine knows how to render Twig templates. * * @author Fabien Potencier + * + * @deprecated since version 4.3, to be removed in 5.0; use Twig instead. */ class TwigEngine implements EngineInterface, StreamingEngineInterface { diff --git a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/TemplateFinder.php b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/TemplateFinder.php index 27c103e26c475..6e5a11cade4a7 100644 --- a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/TemplateFinder.php +++ b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/TemplateFinder.php @@ -11,6 +11,8 @@ namespace Symfony\Bundle\FrameworkBundle\CacheWarmer; +@trigger_error('The '.TemplateFinder::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED); + use Symfony\Component\Finder\Finder; use Symfony\Component\HttpKernel\Bundle\BundleInterface; use Symfony\Component\HttpKernel\KernelInterface; @@ -21,6 +23,8 @@ * Finds all the templates. * * @author Victor Berchet + * + * @deprecated since version 4.3, to be removed in 5.0; use Twig instead. */ class TemplateFinder implements TemplateFinderInterface { diff --git a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/TemplateFinderInterface.php b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/TemplateFinderInterface.php index 433ed8f54897a..f5ed025facfdb 100644 --- a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/TemplateFinderInterface.php +++ b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/TemplateFinderInterface.php @@ -11,10 +11,14 @@ namespace Symfony\Bundle\FrameworkBundle\CacheWarmer; +@trigger_error('The '.TemplateFinderInterface::class.' interface is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED); + /** * Interface for finding all the templates. * * @author Victor Berchet + * + * @deprecated since version 4.3, to be removed in 5.0; use Twig instead. */ interface TemplateFinderInterface { diff --git a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/TemplatePathsCacheWarmer.php b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/TemplatePathsCacheWarmer.php index 6662a1808d5e1..9db00d828b64e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/TemplatePathsCacheWarmer.php +++ b/src/Symfony/Bundle/FrameworkBundle/CacheWarmer/TemplatePathsCacheWarmer.php @@ -11,6 +11,8 @@ namespace Symfony\Bundle\FrameworkBundle\CacheWarmer; +@trigger_error('The '.TemplatePathsCacheWarmer::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED); + use Symfony\Bundle\FrameworkBundle\Templating\Loader\TemplateLocator; use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmer; @@ -19,6 +21,8 @@ * Computes the association between template names and their paths on the disk. * * @author Fabien Potencier + * + * @deprecated since version 4.3, to be removed in 5.0; use Twig instead. */ class TemplatePathsCacheWarmer extends CacheWarmer { diff --git a/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerTrait.php b/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerTrait.php index 0650fea5cac7f..e32f7b6e25d0a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerTrait.php +++ b/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerTrait.php @@ -206,6 +206,8 @@ protected function denyAccessUnlessGranted($attributes, $subject = null, string protected function renderView(string $view, array $parameters = []): string { if ($this->container->has('templating')) { + @trigger_error('Using the "templating" service is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED); + return $this->container->get('templating')->render($view, $parameters); } @@ -224,6 +226,8 @@ protected function renderView(string $view, array $parameters = []): string protected function render(string $view, array $parameters = [], Response $response = null): Response { if ($this->container->has('templating')) { + @trigger_error('Using the "templating" service is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED); + $content = $this->container->get('templating')->render($view, $parameters); } elseif ($this->container->has('twig')) { $content = $this->container->get('twig')->render($view, $parameters); @@ -248,6 +252,8 @@ protected function render(string $view, array $parameters = [], Response $respon protected function stream(string $view, array $parameters = [], StreamedResponse $response = null): StreamedResponse { if ($this->container->has('templating')) { + @trigger_error('Using the "templating" service is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED); + $templating = $this->container->get('templating'); $callback = function () use ($templating, $view, $parameters) { diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/TemplatingPass.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/TemplatingPass.php index 4eff0b6c8eb64..be7418d909726 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/TemplatingPass.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/TemplatingPass.php @@ -18,6 +18,9 @@ use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\Templating\EngineInterface as ComponentEngineInterface; +/** + * @deprecated since version 4.3, to be removed in 5.0; use Twig instead. + */ class TemplatingPass implements CompilerPassInterface { public function process(ContainerBuilder $container) @@ -34,7 +37,12 @@ public function process(ContainerBuilder $container) if ($container->hasDefinition('templating.engine.php')) { $refs = []; $helpers = []; + foreach ($container->findTaggedServiceIds('templating.helper', true) as $id => $attributes) { + if (!$container->getDefinition($id)->isDeprecated()) { + @trigger_error('The "templating.helper" tag is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED); + } + if (isset($attributes[0]['alias'])) { $helpers[$attributes[0]['alias']] = $id; $refs[$id] = new Reference($id); diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index ef6a2147e36f5..870c499aafbd6 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -264,6 +264,8 @@ public function load(array $configs, ContainerBuilder $container) } if ($this->isConfigEnabled($container, $config['templating'])) { + @trigger_error('Enabling the Templating component is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED); + if (!class_exists('Symfony\Component\Templating\PhpEngine')) { throw new LogicException('Templating support cannot be enabled as the Templating component is not installed. Try running "composer require symfony/templating".'); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/templating.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/templating.xml index 83c904f16f403..b6b70be999de8 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/templating.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/templating.xml @@ -10,10 +10,14 @@ + + The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0. + + The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0. @@ -21,30 +25,41 @@ %kernel.cache_dir% + + The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0. %kernel.root_dir%/Resources + + The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0. + + The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0. + + The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0. %templating.loader.cache.path% + + The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0. + The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0. diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/templating_debug.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/templating_debug.xml index f6cfd4ae68dfb..3dd7b84c123ba 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/templating_debug.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/templating_debug.xml @@ -14,6 +14,8 @@ %kernel.charset% + + The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0. diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/templating_php.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/templating_php.xml index 06ab2f41fcdea..440b9a5d23298 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/templating_php.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/templating_php.xml @@ -13,6 +13,8 @@ %kernel.charset% + + The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0. @@ -22,31 +24,43 @@ + + The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0. + + The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0. + + The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0. + + The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0. + + The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0. + + The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0. @@ -54,35 +68,49 @@ %kernel.project_dir% %kernel.charset% + + The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0. + + The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0. + + The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0. + + The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0. %templating.helper.form.resources% + + The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0. + + The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0. + + The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0. diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/DelegatingEngine.php b/src/Symfony/Bundle/FrameworkBundle/Templating/DelegatingEngine.php index f40760fc91eb6..bd292e468160b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/DelegatingEngine.php +++ b/src/Symfony/Bundle/FrameworkBundle/Templating/DelegatingEngine.php @@ -11,6 +11,8 @@ namespace Symfony\Bundle\FrameworkBundle\Templating; +@trigger_error('The '.DelegatingEngine::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED); + use Psr\Container\ContainerInterface; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Templating\DelegatingEngine as BaseDelegatingEngine; @@ -19,6 +21,8 @@ * DelegatingEngine selects an engine for a given template. * * @author Fabien Potencier + * + * @deprecated since version 4.3, to be removed in 5.0; use Twig instead. */ class DelegatingEngine extends BaseDelegatingEngine implements EngineInterface { diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/EngineInterface.php b/src/Symfony/Bundle/FrameworkBundle/Templating/EngineInterface.php index 0b3a8b32006b3..2539980b9d960 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/EngineInterface.php +++ b/src/Symfony/Bundle/FrameworkBundle/Templating/EngineInterface.php @@ -11,6 +11,8 @@ namespace Symfony\Bundle\FrameworkBundle\Templating; +@trigger_error('The '.EngineInterface::class.' interface is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED); + use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Templating\EngineInterface as BaseEngineInterface; @@ -18,6 +20,8 @@ * EngineInterface is the interface each engine must implement. * * @author Fabien Potencier + * + * @deprecated since version 4.3, to be removed in 5.0; use Twig instead. */ interface EngineInterface extends BaseEngineInterface { diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/GlobalVariables.php b/src/Symfony/Bundle/FrameworkBundle/Templating/GlobalVariables.php index 4e07b9b5b8be3..2981eb66422d1 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/GlobalVariables.php +++ b/src/Symfony/Bundle/FrameworkBundle/Templating/GlobalVariables.php @@ -11,6 +11,8 @@ namespace Symfony\Bundle\FrameworkBundle\Templating; +@trigger_error('The '.GlobalVariables::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED); + use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Session\Session; @@ -20,6 +22,8 @@ * GlobalVariables is the entry point for Symfony global variables in PHP templates. * * @author Fabien Potencier + * + * @deprecated since version 4.3, to be removed in 5.0; use Twig instead. */ class GlobalVariables { diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/ActionsHelper.php b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/ActionsHelper.php index 70e5a314bba64..8a054162fb81a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/ActionsHelper.php +++ b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/ActionsHelper.php @@ -11,6 +11,8 @@ namespace Symfony\Bundle\FrameworkBundle\Templating\Helper; +@trigger_error('The '.ActionsHelper::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED); + use Symfony\Component\HttpKernel\Controller\ControllerReference; use Symfony\Component\HttpKernel\Fragment\FragmentHandler; use Symfony\Component\Templating\Helper\Helper; @@ -19,6 +21,8 @@ * ActionsHelper manages action inclusions. * * @author Fabien Potencier + * + * @deprecated since version 4.3, to be removed in 5.0; use Twig instead. */ class ActionsHelper extends Helper { diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/AssetsHelper.php b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/AssetsHelper.php index 072b6e7fc9302..ff237d6a9728a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/AssetsHelper.php +++ b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/AssetsHelper.php @@ -11,6 +11,8 @@ namespace Symfony\Bundle\FrameworkBundle\Templating\Helper; +@trigger_error('The '.AssetsHelper::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED); + use Symfony\Component\Asset\Packages; use Symfony\Component\Templating\Helper\Helper; @@ -18,6 +20,8 @@ * AssetsHelper helps manage asset URLs. * * @author Fabien Potencier + * + * @deprecated since version 4.3, to be removed in 5.0; use Twig instead. */ class AssetsHelper extends Helper { diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/CodeHelper.php b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/CodeHelper.php index 56fcc24cf0594..1d8885ba40b54 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/CodeHelper.php +++ b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/CodeHelper.php @@ -11,13 +11,17 @@ namespace Symfony\Bundle\FrameworkBundle\Templating\Helper; +@trigger_error('The '.CodeHelper::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED); + use Symfony\Component\HttpKernel\Debug\FileLinkFormatter; use Symfony\Component\Templating\Helper\Helper; /** * @author Fabien Potencier * - * @internal since Symfony 4.2, all properties will be private in 5.0 + * @internal since Symfony 4.2 + * + * @deprecated since version 4.3, to be removed in 5.0; use Twig instead. */ class CodeHelper extends Helper { diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/FormHelper.php b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/FormHelper.php index dd1d14149a1a4..0956d31adaf13 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/FormHelper.php +++ b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/FormHelper.php @@ -11,6 +11,8 @@ namespace Symfony\Bundle\FrameworkBundle\Templating\Helper; +@trigger_error('The '.FormHelper::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED); + use Symfony\Component\Form\FormRendererInterface; use Symfony\Component\Form\FormView; use Symfony\Component\Templating\Helper\Helper; @@ -20,6 +22,8 @@ * * @author Fabien Potencier * @author Bernhard Schussek + * + * @deprecated since version 4.3, to be removed in 5.0; use Twig instead. */ class FormHelper extends Helper { diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/RequestHelper.php b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/RequestHelper.php index 3beaaada2aced..351ed712c4a54 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/RequestHelper.php +++ b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/RequestHelper.php @@ -11,6 +11,8 @@ namespace Symfony\Bundle\FrameworkBundle\Templating\Helper; +@trigger_error('The '.RequestHelper::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED); + use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\Templating\Helper\Helper; @@ -18,6 +20,8 @@ * RequestHelper provides access to the current request parameters. * * @author Fabien Potencier + * + * @deprecated since version 4.3, to be removed in 5.0; use Twig instead. */ class RequestHelper extends Helper { diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/RouterHelper.php b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/RouterHelper.php index f242479086e9a..0854fe3f048bd 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/RouterHelper.php +++ b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/RouterHelper.php @@ -11,6 +11,8 @@ namespace Symfony\Bundle\FrameworkBundle\Templating\Helper; +@trigger_error('The '.RouterHelper::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED); + use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Component\Templating\Helper\Helper; @@ -18,6 +20,8 @@ * RouterHelper manages links between pages in a template context. * * @author Fabien Potencier + * + * @deprecated since version 4.3, to be removed in 5.0; use Twig instead. */ class RouterHelper extends Helper { diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/SessionHelper.php b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/SessionHelper.php index 072c1d3d21467..86c0fcda1b936 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/SessionHelper.php +++ b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/SessionHelper.php @@ -11,6 +11,8 @@ namespace Symfony\Bundle\FrameworkBundle\Templating\Helper; +@trigger_error('The '.SessionHelper::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED); + use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\Templating\Helper\Helper; @@ -18,6 +20,8 @@ * SessionHelper provides read-only access to the session attributes. * * @author Fabien Potencier + * + * @deprecated since version 4.3, to be removed in 5.0; use Twig instead. */ class SessionHelper extends Helper { diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/StopwatchHelper.php b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/StopwatchHelper.php index 1b16d47dbb3f8..9ec4df47a1323 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/StopwatchHelper.php +++ b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/StopwatchHelper.php @@ -11,6 +11,8 @@ namespace Symfony\Bundle\FrameworkBundle\Templating\Helper; +@trigger_error('The '.StopwatchHelper::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED); + use Symfony\Component\Stopwatch\Stopwatch; use Symfony\Component\Templating\Helper\Helper; @@ -18,6 +20,8 @@ * StopwatchHelper provides methods time your PHP templates. * * @author Wouter J + * + * @deprecated since version 4.3, to be removed in 5.0; use Twig instead. */ class StopwatchHelper extends Helper { diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/TranslatorHelper.php b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/TranslatorHelper.php index 5debaae9d6749..b86c0da666aa2 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/TranslatorHelper.php +++ b/src/Symfony/Bundle/FrameworkBundle/Templating/Helper/TranslatorHelper.php @@ -11,6 +11,8 @@ namespace Symfony\Bundle\FrameworkBundle\Templating\Helper; +@trigger_error('The '.TranslatorHelper::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED); + use Symfony\Component\Templating\Helper\Helper; use Symfony\Component\Translation\TranslatorInterface as LegacyTranslatorInterface; use Symfony\Contracts\Translation\TranslatorInterface; @@ -18,6 +20,8 @@ /** * @author Fabien Potencier + * + * @deprecated since version 4.3, to be removed in 5.0; use Twig instead. */ class TranslatorHelper extends Helper { diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/Loader/FilesystemLoader.php b/src/Symfony/Bundle/FrameworkBundle/Templating/Loader/FilesystemLoader.php index 4edceed8ab7ea..52edeb86199fe 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/Loader/FilesystemLoader.php +++ b/src/Symfony/Bundle/FrameworkBundle/Templating/Loader/FilesystemLoader.php @@ -11,6 +11,8 @@ namespace Symfony\Bundle\FrameworkBundle\Templating\Loader; +@trigger_error('The '.FilesystemLoader::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED); + use Symfony\Component\Config\FileLocatorInterface; use Symfony\Component\Templating\Loader\LoaderInterface; use Symfony\Component\Templating\Storage\FileStorage; @@ -20,6 +22,8 @@ * FilesystemLoader is a loader that read templates from the filesystem. * * @author Fabien Potencier + * + * @deprecated since version 4.3, to be removed in 5.0; use Twig instead. */ class FilesystemLoader implements LoaderInterface { diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/Loader/TemplateLocator.php b/src/Symfony/Bundle/FrameworkBundle/Templating/Loader/TemplateLocator.php index 4e4743dcc51f8..39ebe0e1d3d45 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/Loader/TemplateLocator.php +++ b/src/Symfony/Bundle/FrameworkBundle/Templating/Loader/TemplateLocator.php @@ -11,6 +11,8 @@ namespace Symfony\Bundle\FrameworkBundle\Templating\Loader; +@trigger_error('The '.TemplateLocator::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED); + use Symfony\Component\Config\FileLocatorInterface; use Symfony\Component\Templating\TemplateReferenceInterface; @@ -18,6 +20,8 @@ * TemplateLocator locates templates in bundles. * * @author Fabien Potencier + * + * @deprecated since version 4.3, to be removed in 5.0; use Twig instead. */ class TemplateLocator implements FileLocatorInterface { diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/PhpEngine.php b/src/Symfony/Bundle/FrameworkBundle/Templating/PhpEngine.php index ef9c43b8fd456..080d0b7815210 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/PhpEngine.php +++ b/src/Symfony/Bundle/FrameworkBundle/Templating/PhpEngine.php @@ -11,6 +11,8 @@ namespace Symfony\Bundle\FrameworkBundle\Templating; +@trigger_error('The '.PhpEngine::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED); + use Psr\Container\ContainerInterface; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Templating\Loader\LoaderInterface; @@ -21,6 +23,8 @@ * This engine knows how to render Symfony templates. * * @author Fabien Potencier + * + * @deprecated since version 4.3, to be removed in 5.0; use Twig instead. */ class PhpEngine extends BasePhpEngine implements EngineInterface { diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/TemplateFilenameParser.php b/src/Symfony/Bundle/FrameworkBundle/Templating/TemplateFilenameParser.php index b6870334c6e3d..de383461d7f8a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/TemplateFilenameParser.php +++ b/src/Symfony/Bundle/FrameworkBundle/Templating/TemplateFilenameParser.php @@ -11,6 +11,8 @@ namespace Symfony\Bundle\FrameworkBundle\Templating; +@trigger_error('The '.TemplateFilenameParser::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED); + use Symfony\Component\Templating\TemplateNameParserInterface; use Symfony\Component\Templating\TemplateReferenceInterface; @@ -19,6 +21,8 @@ * TemplateReferenceInterface instances. * * @author Fabien Potencier + * + * @deprecated since version 4.3, to be removed in 5.0; use Twig instead. */ class TemplateFilenameParser implements TemplateNameParserInterface { diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/TemplateNameParser.php b/src/Symfony/Bundle/FrameworkBundle/Templating/TemplateNameParser.php index d1be3e9074a6e..ffa9a923f1f9d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/TemplateNameParser.php +++ b/src/Symfony/Bundle/FrameworkBundle/Templating/TemplateNameParser.php @@ -11,6 +11,8 @@ namespace Symfony\Bundle\FrameworkBundle\Templating; +@trigger_error('The '.TemplateNameParser::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED); + use Symfony\Component\HttpKernel\KernelInterface; use Symfony\Component\Templating\TemplateNameParser as BaseTemplateNameParser; use Symfony\Component\Templating\TemplateReferenceInterface; @@ -21,6 +23,8 @@ * instances. * * @author Fabien Potencier + * + * @deprecated since version 4.3, to be removed in 5.0; use Twig instead. */ class TemplateNameParser extends BaseTemplateNameParser { diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/TemplateReference.php b/src/Symfony/Bundle/FrameworkBundle/Templating/TemplateReference.php index 830942972a521..3bc461ebb66e8 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/TemplateReference.php +++ b/src/Symfony/Bundle/FrameworkBundle/Templating/TemplateReference.php @@ -11,12 +11,16 @@ namespace Symfony\Bundle\FrameworkBundle\Templating; +@trigger_error('The '.TemplateReference::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED); + use Symfony\Component\Templating\TemplateReference as BaseTemplateReference; /** * Internal representation of a template. * * @author Victor Berchet + * + * @deprecated since version 4.3, to be removed in 5.0; use Twig instead. */ class TemplateReference extends BaseTemplateReference { diff --git a/src/Symfony/Bundle/FrameworkBundle/Templating/TimedPhpEngine.php b/src/Symfony/Bundle/FrameworkBundle/Templating/TimedPhpEngine.php index 783e675f975af..faa7c55fae63b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Templating/TimedPhpEngine.php +++ b/src/Symfony/Bundle/FrameworkBundle/Templating/TimedPhpEngine.php @@ -11,6 +11,8 @@ namespace Symfony\Bundle\FrameworkBundle\Templating; +@trigger_error('The '.TimedPhpEngine::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED); + use Psr\Container\ContainerInterface; use Symfony\Component\Stopwatch\Stopwatch; use Symfony\Component\Templating\Loader\LoaderInterface; @@ -20,6 +22,8 @@ * Times the time spent to render a template. * * @author Fabien Potencier + * + * @deprecated since version 4.3, to be removed in 5.0; use Twig instead. */ class TimedPhpEngine extends PhpEngine { diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/TemplateFinderTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/TemplateFinderTest.php index 94b5432c3ab9b..ad12c38c3e750 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/TemplateFinderTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/TemplateFinderTest.php @@ -16,6 +16,9 @@ use Symfony\Bundle\FrameworkBundle\Tests\Fixtures\BaseBundle\BaseBundle; use Symfony\Bundle\FrameworkBundle\Tests\TestCase; +/** + * @group legacy + */ class TemplateFinderTest extends TestCase { public function testFindAllTemplates() diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/TemplatePathsCacheWarmerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/TemplatePathsCacheWarmerTest.php index 30d0242663723..209887696a20f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/TemplatePathsCacheWarmerTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/CacheWarmer/TemplatePathsCacheWarmerTest.php @@ -19,6 +19,9 @@ use Symfony\Component\Config\FileLocator; use Symfony\Component\Filesystem\Filesystem; +/** + * @group legacy + */ class TemplatePathsCacheWarmerTest extends TestCase { /** @var Filesystem */ diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTraitTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTraitTest.php index 8bd22bed79cae..179b6edc0c475 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTraitTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTraitTest.php @@ -439,6 +439,9 @@ public function testRedirect() $this->assertSame(301, $response->getStatusCode()); } + /** + * @group legacy + */ public function testRenderViewTemplating() { $templating = $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Templating\EngineInterface')->getMock(); @@ -453,6 +456,9 @@ public function testRenderViewTemplating() $this->assertEquals('bar', $controller->renderView('foo')); } + /** + * @group legacy + */ public function testRenderTemplating() { $templating = $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Templating\EngineInterface')->getMock(); @@ -467,6 +473,9 @@ public function testRenderTemplating() $this->assertEquals('bar', $controller->render('foo')->getContent()); } + /** + * @group legacy + */ public function testStreamTemplating() { $templating = $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Templating\EngineInterface')->getMock(); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/full.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/full.php index 8684a569a9234..e02ba9183f5e6 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/full.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/full.php @@ -39,15 +39,6 @@ 'gc_probability' => 1, 'save_path' => '/path/to/sessions', ], - 'templating' => [ - 'cache' => '/path/to/cache', - 'engines' => ['php', 'twig'], - 'loader' => ['loader.foo', 'loader.bar'], - 'form' => [ - 'resources' => ['theme1', 'theme2'], - ], - 'hinclude_default_template' => 'global_hinclude_template', - ], 'assets' => [ 'version' => 'v1', ], diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/templating.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/templating.php new file mode 100644 index 0000000000000..162d09199fd86 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/templating.php @@ -0,0 +1,14 @@ +loadFromExtension('framework', array( + 'templating' => array( + 'cache' => '/path/to/cache', + 'engines' => array('php', 'twig'), + 'loader' => array('loader.foo', 'loader.bar'), + 'form' => array( + 'resources' => array('theme1', 'theme2'), + ), + 'hinclude_default_template' => 'global_hinclude_template', + ), + 'assets' => null, +)); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/full.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/full.xml index ed4b14671eca6..905c187ef8857 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/full.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/full.xml @@ -25,16 +25,6 @@ application/pdf - - loader.foo - loader.bar - php - twig - - theme1 - theme2 - - %kernel.project_dir%/Fixtures/translations diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/templating.xml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/templating.xml new file mode 100644 index 0000000000000..192533dbf617a --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/templating.xml @@ -0,0 +1,22 @@ + + + + + + + + loader.foo + loader.bar + php + twig + + theme1 + theme2 + + + + diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/full.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/full.yml index 0751eb933e584..9194911b063c5 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/full.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/full.yml @@ -30,13 +30,6 @@ framework: gc_divisor: 108 gc_maxlifetime: 90000 save_path: /path/to/sessions - templating: - engines: [php, twig] - loader: [loader.foo, loader.bar] - cache: /path/to/cache - form: - resources: [theme1, theme2] - hinclude_default_template: global_hinclude_template assets: version: v1 translator: diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/templating.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/templating.yml new file mode 100644 index 0000000000000..d307e1609b090 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/templating.yml @@ -0,0 +1,9 @@ +framework: + templating: + engines: [php, twig] + loader: [loader.foo, loader.bar] + cache: /path/to/cache + form: + resources: [theme1, theme2] + hinclude_default_template: global_hinclude_template + assets: ~ diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php index 0c0b5cc6c3333..0e6eff1e1076c 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php @@ -533,9 +533,12 @@ public function testEmptyRequestFormats() $this->assertFalse($container->hasDefinition('request.add_request_formats_listener'), '->registerRequestConfiguration() does not load request.xml when no request formats are defined'); } + /** + * @group legacy + */ public function testTemplating() { - $container = $this->createContainerFromFile('full'); + $container = $this->createContainerFromFile('templating'); $this->assertTrue($container->hasDefinition('templating.name_parser'), '->registerTemplatingConfiguration() loads templating.xml'); @@ -1197,14 +1200,20 @@ public function testSerializerMapping() $this->assertEquals($expectedLoaders, $loaders); } + /** + * @group legacy + */ public function testAssetHelperWhenAssetsAreEnabled() { - $container = $this->createContainerFromFile('full'); + $container = $this->createContainerFromFile('templating'); $packages = $container->getDefinition('templating.helper.assets')->getArgument(0); $this->assertSame('assets.packages', (string) $packages); } + /** + * @group legacy + */ public function testAssetHelperWhenTemplatesAreEnabledAndNoAssetsConfiguration() { $container = $this->createContainerFromFile('templating_no_assets'); @@ -1213,6 +1222,9 @@ public function testAssetHelperWhenTemplatesAreEnabledAndNoAssetsConfiguration() $this->assertSame('assets.packages', (string) $packages); } + /** + * @group legacy + */ public function testAssetsHelperIsRemovedWhenPhpTemplatingEngineIsEnabledAndAssetsAreDisabled() { $container = $this->createContainerFromFile('templating_php_assets_disabled'); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/AutowiringTypesTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/AutowiringTypesTest.php index 43f91f5213409..8e582b13a89a0 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/AutowiringTypesTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/AutowiringTypesTest.php @@ -37,9 +37,12 @@ public function testCachedAnnotationReaderAutowiring() $this->assertInstanceOf(CachedReader::class, $annotationReader); } + /** + * @group legacy + */ public function testTemplatingAutowiring() { - static::bootKernel(); + static::bootKernel(array('root_config' => 'templating.yml', 'environment' => 'templating')); $autowiredServices = static::$container->get('test.autowiring_types.autowired_services'); $this->assertInstanceOf(FrameworkBundleEngineInterface::class, $autowiredServices->getFrameworkBundleEngine()); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/AutowiringTypes/AutowiredServices.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/AutowiringTypes/AutowiredServices.php index a62cdf64dfa04..d9a7b59d46ba6 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/AutowiringTypes/AutowiredServices.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/AutowiringTypes/AutowiredServices.php @@ -13,23 +13,17 @@ use Doctrine\Common\Annotations\Reader; use Psr\Cache\CacheItemPoolInterface; -use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface as FrameworkBundleEngineInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; -use Symfony\Component\Templating\EngineInterface; class AutowiredServices { private $annotationReader; - private $frameworkBundleEngine; - private $engine; private $dispatcher; private $cachePool; - public function __construct(Reader $annotationReader = null, FrameworkBundleEngineInterface $frameworkBundleEngine, EngineInterface $engine, EventDispatcherInterface $dispatcher, CacheItemPoolInterface $cachePool) + public function __construct(Reader $annotationReader = null, EventDispatcherInterface $dispatcher, CacheItemPoolInterface $cachePool) { $this->annotationReader = $annotationReader; - $this->frameworkBundleEngine = $frameworkBundleEngine; - $this->engine = $engine; $this->dispatcher = $dispatcher; $this->cachePool = $cachePool; } @@ -39,16 +33,6 @@ public function getAnnotationReader() return $this->annotationReader; } - public function getFrameworkBundleEngine() - { - return $this->frameworkBundleEngine; - } - - public function getEngine() - { - return $this->engine; - } - public function getDispatcher() { return $this->dispatcher; diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/AutowiringTypes/TemplatingServices.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/AutowiringTypes/TemplatingServices.php new file mode 100644 index 0000000000000..7fc0cdd7b55af --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/AutowiringTypes/TemplatingServices.php @@ -0,0 +1,31 @@ + + */ +class TemplatingServices +{ + private $frameworkBundleEngine; + private $engine; + + public function __construct(FrameworkBundleEngineInterface $frameworkBundleEngine, EngineInterface $engine) + { + $this->frameworkBundleEngine = $frameworkBundleEngine; + $this->engine = $engine; + } + + public function getFrameworkBundleEngine() + { + return $this->frameworkBundleEngine; + } + + public function getEngine() + { + return $this->engine; + } +} diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Controller/FragmentController.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Controller/FragmentController.php index aa78c87190e60..8436a3b24809a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Controller/FragmentController.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/Controller/FragmentController.php @@ -15,14 +15,15 @@ use Symfony\Component\DependencyInjection\ContainerAwareTrait; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; +use Twig\Environment; class FragmentController implements ContainerAwareInterface { use ContainerAwareTrait; - public function indexAction(Request $request) + public function indexAction(Environment $twig) { - return $this->container->get('templating')->renderResponse('fragment.html.php', ['bar' => new Bar()]); + return new Response($twig->render('fragment.html.twig', ['bar' => new Bar()])); } public function inlinedAction($options, $_format) diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/FragmentTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/FragmentTest.php index db550a23129ba..d3dbeb765bf6b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/FragmentTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/FragmentTest.php @@ -18,14 +18,23 @@ class FragmentTest extends WebTestCase */ public function testFragment($insulate) { - $client = $this->createClient(['test_case' => 'Fragment', 'root_config' => 'config.yml']); + $client = $this->createClient(['test_case' => 'Fragment', 'root_config' => 'config.yml', 'debug' => true]); if ($insulate) { $client->insulate(); } $client->request('GET', '/fragment_home'); - $this->assertEquals('bar txt--html--es--fr', $client->getResponse()->getContent()); + $this->assertEquals(<<getResponse()->getContent()); } public function getConfigs() diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AutowiringTypes/config.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AutowiringTypes/config.yml index 1b47c1100a159..93fd9eefac5c1 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AutowiringTypes/config.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AutowiringTypes/config.yml @@ -6,6 +6,3 @@ services: test.autowiring_types.autowired_services: class: Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\AutowiringTypes\AutowiredServices autowire: true -framework: - templating: - engines: ['php'] diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AutowiringTypes/templating.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AutowiringTypes/templating.yml new file mode 100644 index 0000000000000..765bfa9d70d48 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/AutowiringTypes/templating.yml @@ -0,0 +1,12 @@ +imports: + - { resource: ../config/default.yml } + +services: + _defaults: { public: true } + test.autowiring_types.autowired_services: + class: Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\AutowiringTypes\TemplatingServices + autowire: true + +framework: + templating: + engines: ['php'] diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ContainerDump/config.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ContainerDump/config.yml index 29f1e32ff964f..5754ba969365b 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ContainerDump/config.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/ContainerDump/config.yml @@ -9,9 +9,6 @@ framework: router: true session: true request: true - templating: - enabled: true - engines: ['php'] assets: true translator: true validation: true diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Fragment/bundles.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Fragment/bundles.php index 15ff182c6fed5..50676b63646eb 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Fragment/bundles.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Fragment/bundles.php @@ -11,8 +11,10 @@ use Symfony\Bundle\FrameworkBundle\FrameworkBundle; use Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\TestBundle; +use Symfony\Bundle\TwigBundle\TwigBundle; return [ new FrameworkBundle(), + new TwigBundle(), new TestBundle(), ]; diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Fragment/config.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Fragment/config.yml index f7ea83dfa7cef..16fc81dd268d4 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Fragment/config.yml +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Fragment/config.yml @@ -1,7 +1,9 @@ imports: - { resource: ../config/default.yml } + - { resource: services.yml } framework: fragments: ~ - templating: - engines: ['php'] + +twig: + strict_variables: '%kernel.debug%' diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Fragment/services.yml b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Fragment/services.yml new file mode 100644 index 0000000000000..be54586434da5 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Fragment/services.yml @@ -0,0 +1,6 @@ +services: + _defaults: + public: true + + Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\Controller\FragmentController: + tags: ['controller.service_arguments'] diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Resources/views/fragment.html.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Resources/views/fragment.html.php deleted file mode 100644 index 0e89a5b36ccc6..0000000000000 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Resources/views/fragment.html.php +++ /dev/null @@ -1,14 +0,0 @@ -get('actions')->render($this->get('actions')->controller('Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\Controller\FragmentController::inlinedAction', [ - 'options' => [ - 'bar' => $bar, - 'eleven' => 11, - ], - ])); -?>--get('actions')->render($this->get('actions')->controller('Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\Controller\FragmentController::customformatAction', ['_format' => 'html'])); -?>--get('actions')->render($this->get('actions')->controller('Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\Controller\FragmentController::customlocaleAction', ['_locale' => 'es'])); -?>--getRequest()->setLocale('fr'); - echo $this->get('actions')->render($this->get('actions')->controller('Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\Controller\FragmentController::forwardlocaleAction')); -?> diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/templates/fragment.html.twig b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/templates/fragment.html.twig new file mode 100644 index 0000000000000..4dea4b360b68b --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/templates/fragment.html.twig @@ -0,0 +1,7 @@ +{{ render(controller('TestBundle:Fragment:inlined', {'options': {'bar': bar, 'eleven': 11}})) }} +-- +{{ render(controller('TestBundle:Fragment:customformat', {'_format': 'html'})) }} +-- +{{ render(controller('TestBundle:Fragment:customlocale', {'_locale': 'es'})) }} +-- +{{ app.request.setLocale('fr') }}{{ render(controller('TestBundle:Fragment:forwardlocale')) -}} diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/DelegatingEngineTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/DelegatingEngineTest.php index 73983e47ce363..8d5eb96a53c31 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/DelegatingEngineTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/DelegatingEngineTest.php @@ -15,6 +15,9 @@ use Symfony\Bundle\FrameworkBundle\Templating\DelegatingEngine; use Symfony\Component\HttpFoundation\Response; +/** + * @group legacy + */ class DelegatingEngineTest extends TestCase { public function testSupportsRetrievesEngineFromTheContainer() diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/GlobalVariablesTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/GlobalVariablesTest.php index d6c6b299ebc62..984a2388e97b8 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/GlobalVariablesTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/GlobalVariablesTest.php @@ -15,6 +15,9 @@ use Symfony\Bundle\FrameworkBundle\Tests\TestCase; use Symfony\Component\DependencyInjection\Container; +/** + * @group legacy + */ class GlobalVariablesTest extends TestCase { private $container; diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/AssetsHelperTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/AssetsHelperTest.php index 83df0640bfaee..06e87f43f72ff 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/AssetsHelperTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/AssetsHelperTest.php @@ -17,6 +17,9 @@ use Symfony\Component\Asset\Packages; use Symfony\Component\Asset\VersionStrategy\StaticVersionStrategy; +/** + * @group legacy + */ class AssetsHelperTest extends TestCase { private $helper; diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/FormHelperDivLayoutTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/FormHelperDivLayoutTest.php index 35dbc03f3433b..729b01920f7d6 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/FormHelperDivLayoutTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/FormHelperDivLayoutTest.php @@ -20,6 +20,9 @@ use Symfony\Component\Templating\Loader\FilesystemLoader; use Symfony\Component\Templating\PhpEngine; +/** + * @group legacy + */ class FormHelperDivLayoutTest extends AbstractDivLayoutTest { /** diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/FormHelperTableLayoutTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/FormHelperTableLayoutTest.php index 262421bf34bb9..8e335788ea335 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/FormHelperTableLayoutTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/FormHelperTableLayoutTest.php @@ -20,6 +20,9 @@ use Symfony\Component\Templating\Loader\FilesystemLoader; use Symfony\Component\Templating\PhpEngine; +/** + * @group legacy + */ class FormHelperTableLayoutTest extends AbstractTableLayoutTest { /** diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/RequestHelperTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/RequestHelperTest.php index a2068ae757741..d29b5c0ff47b6 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/RequestHelperTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/RequestHelperTest.php @@ -16,6 +16,9 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RequestStack; +/** + * @group legacy + */ class RequestHelperTest extends TestCase { protected $requestStack; diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/SessionHelperTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/SessionHelperTest.php index 06984095f1a4b..c9521e8e54074 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/SessionHelperTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/SessionHelperTest.php @@ -18,6 +18,9 @@ use Symfony\Component\HttpFoundation\Session\Session; use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage; +/** + * @group legacy + */ class SessionHelperTest extends TestCase { protected $requestStack; diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/StopwatchHelperTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/StopwatchHelperTest.php index 686c655aac8f2..f5030b4e79fc1 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/StopwatchHelperTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/StopwatchHelperTest.php @@ -14,6 +14,9 @@ use PHPUnit\Framework\TestCase; use Symfony\Bundle\FrameworkBundle\Templating\Helper\StopwatchHelper; +/** + * @group legacy + */ class StopwatchHelperTest extends TestCase { public function testDevEnvironment() diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Loader/TemplateLocatorTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Loader/TemplateLocatorTest.php index 3317b15d90914..fbe8125b9ac0e 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Loader/TemplateLocatorTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Loader/TemplateLocatorTest.php @@ -15,6 +15,9 @@ use Symfony\Bundle\FrameworkBundle\Templating\TemplateReference; use Symfony\Bundle\FrameworkBundle\Tests\TestCase; +/** + * @group legacy + */ class TemplateLocatorTest extends TestCase { public function testLocateATemplate() diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/PhpEngineTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/PhpEngineTest.php index 9628828afaecb..47f3f360aa747 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/PhpEngineTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/PhpEngineTest.php @@ -21,6 +21,9 @@ use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage; use Symfony\Component\Templating\TemplateNameParser; +/** + * @group legacy + */ class PhpEngineTest extends TestCase { public function testEvaluateAddsAppGlobal() diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateFilenameParserTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateFilenameParserTest.php index 3c44612b87631..305be175910b8 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateFilenameParserTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateFilenameParserTest.php @@ -15,6 +15,9 @@ use Symfony\Bundle\FrameworkBundle\Templating\TemplateReference; use Symfony\Bundle\FrameworkBundle\Tests\TestCase; +/** + * @group legacy + */ class TemplateFilenameParserTest extends TestCase { protected $parser; diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateNameParserTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateNameParserTest.php index 9b4db5101a0c9..9882fd9a9db0d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateNameParserTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateNameParserTest.php @@ -16,6 +16,9 @@ use Symfony\Bundle\FrameworkBundle\Tests\TestCase; use Symfony\Component\Templating\TemplateReference as BaseTemplateReference; +/** + * @group legacy + */ class TemplateNameParserTest extends TestCase { protected $parser; diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateReferenceTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateReferenceTest.php index 35561bf52b55c..179c3b6da0dbd 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateReferenceTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateReferenceTest.php @@ -14,6 +14,9 @@ use Symfony\Bundle\FrameworkBundle\Templating\TemplateReference; use Symfony\Bundle\FrameworkBundle\Tests\TestCase; +/** + * @group legacy + */ class TemplateReferenceTest extends TestCase { public function testGetPathWorksWithNamespacedControllers() diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateTest.php index 66872049ad995..899740169f207 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateTest.php @@ -14,6 +14,9 @@ use Symfony\Bundle\FrameworkBundle\Templating\TemplateReference; use Symfony\Bundle\FrameworkBundle\Tests\TestCase; +/** + * @group legacy + */ class TemplateTest extends TestCase { /** diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TimedPhpEngineTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TimedPhpEngineTest.php index bd02809dc0173..1347cccf577fc 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TimedPhpEngineTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TimedPhpEngineTest.php @@ -16,6 +16,9 @@ use Symfony\Bundle\FrameworkBundle\Tests\TestCase; use Symfony\Component\DependencyInjection\Container; +/** + * @group legacy + */ class TimedPhpEngineTest extends TestCase { public function testThatRenderLogsTime() diff --git a/src/Symfony/Bundle/FrameworkBundle/composer.json b/src/Symfony/Bundle/FrameworkBundle/composer.json index f065dafc66adb..2a0ba94f875a6 100644 --- a/src/Symfony/Bundle/FrameworkBundle/composer.json +++ b/src/Symfony/Bundle/FrameworkBundle/composer.json @@ -52,6 +52,7 @@ "symfony/stopwatch": "~3.4|~4.0", "symfony/translation": "~4.2", "symfony/templating": "~3.4|~4.0", + "symfony/twig-bundle": "~2.8|~3.2|~4.0", "symfony/validator": "^4.1", "symfony/var-dumper": "~3.4|~4.0", "symfony/workflow": "^4.1", diff --git a/src/Symfony/Bundle/TwigBundle/Tests/Functional/CacheWarmingTest.php b/src/Symfony/Bundle/TwigBundle/Tests/Functional/CacheWarmingTest.php index c5999752d04e6..ca21df09029b9 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/Functional/CacheWarmingTest.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/Functional/CacheWarmingTest.php @@ -18,6 +18,9 @@ use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\HttpKernel\Kernel; +/** + * @group legacy + */ class CacheWarmingTest extends TestCase { public function testCacheIsProperlyWarmedWhenTemplatingIsAvailable() diff --git a/src/Symfony/Bundle/TwigBundle/TwigEngine.php b/src/Symfony/Bundle/TwigBundle/TwigEngine.php index 39115199e5ddd..b8a4995fcd4f0 100644 --- a/src/Symfony/Bundle/TwigBundle/TwigEngine.php +++ b/src/Symfony/Bundle/TwigBundle/TwigEngine.php @@ -11,6 +11,8 @@ namespace Symfony\Bundle\TwigBundle; +@trigger_error('The '.TwigEngine::class.' class is deprecated since version 4.3 and will be removed in 5.0; use \Twig\Environment instead.', E_USER_DEPRECATED); + use Symfony\Bridge\Twig\TwigEngine as BaseEngine; use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface; use Symfony\Bundle\FrameworkBundle\Templating\TemplateReference; @@ -24,6 +26,8 @@ * This engine renders Twig templates. * * @author Fabien Potencier + * + * @deprecated since version 4.3, to be removed in 5.0; use Twig instead. */ class TwigEngine extends BaseEngine implements EngineInterface { From 7169f4d3e27b0365123af2dc7244c14fab167b9d Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 19 Mar 2019 16:45:49 +0100 Subject: [PATCH 2/2] [Templating] added more deprecation --- .../DependencyInjection/SecurityExtension.php | 5 +++- .../Resources/config/templating_php.xml | 4 +++ .../Templating/Helper/LogoutUrlHelper.php | 4 +++ .../Templating/Helper/SecurityHelper.php | 4 +++ .../TwigBundle/Loader/FilesystemLoader.php | 4 +++ .../DependencyInjection/TwigExtensionTest.php | 3 +++ .../Templating/TemplatingExtension.php | 4 +++ .../Templating/TemplatingRendererEngine.php | 4 +++ src/Symfony/Component/Form/Forms.php | 24 ----------------- src/Symfony/Component/Form/composer.json | 3 +-- .../Fragment/HIncludeFragmentRenderer.php | 4 +++ .../Fragment/HIncludeFragmentRendererTest.php | 27 +++++++++---------- .../Component/HttpKernel/composer.json | 3 ++- 13 files changed, 51 insertions(+), 42 deletions(-) diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php index a3d41a70a6a15..4d74daa4d48be 100644 --- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php +++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php @@ -32,6 +32,7 @@ use Symfony\Component\Security\Core\Encoder\Argon2iPasswordEncoder; use Symfony\Component\Security\Core\User\UserProviderInterface; use Symfony\Component\Security\Http\Controller\UserValueResolver; +use Symfony\Component\Templating\PhpEngine; /** * SecurityExtension. @@ -97,7 +98,9 @@ public function load(array $configs, ContainerBuilder $container) $loader->load('security.xml'); $loader->load('security_listeners.xml'); $loader->load('security_rememberme.xml'); - $loader->load('templating_php.xml'); + if (class_exists(PhpEngine::class)) { + $loader->load('templating_php.xml'); + } $loader->load('templating_twig.xml'); $loader->load('collectors.xml'); $loader->load('guard.xml'); diff --git a/src/Symfony/Bundle/SecurityBundle/Resources/config/templating_php.xml b/src/Symfony/Bundle/SecurityBundle/Resources/config/templating_php.xml index b2ce15d1b18bd..b2bafbc60546f 100644 --- a/src/Symfony/Bundle/SecurityBundle/Resources/config/templating_php.xml +++ b/src/Symfony/Bundle/SecurityBundle/Resources/config/templating_php.xml @@ -10,11 +10,15 @@ + + The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0. + + The "%service_id%" service is deprecated since Symfony 4.3 and will be removed in 5.0. diff --git a/src/Symfony/Bundle/SecurityBundle/Templating/Helper/LogoutUrlHelper.php b/src/Symfony/Bundle/SecurityBundle/Templating/Helper/LogoutUrlHelper.php index 3051ed38dc165..30ef9c2829028 100644 --- a/src/Symfony/Bundle/SecurityBundle/Templating/Helper/LogoutUrlHelper.php +++ b/src/Symfony/Bundle/SecurityBundle/Templating/Helper/LogoutUrlHelper.php @@ -11,6 +11,8 @@ namespace Symfony\Bundle\SecurityBundle\Templating\Helper; +@trigger_error('The '.LogoutUrlHelper::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED); + use Symfony\Component\Security\Http\Logout\LogoutUrlGenerator; use Symfony\Component\Templating\Helper\Helper; @@ -18,6 +20,8 @@ * LogoutUrlHelper provides generator functions for the logout URL. * * @author Jeremy Mikola + * + * @deprecated since version 4.3, to be removed in 5.0; use Twig instead. */ class LogoutUrlHelper extends Helper { diff --git a/src/Symfony/Bundle/SecurityBundle/Templating/Helper/SecurityHelper.php b/src/Symfony/Bundle/SecurityBundle/Templating/Helper/SecurityHelper.php index 337748f41b0d8..f6738bd3690df 100644 --- a/src/Symfony/Bundle/SecurityBundle/Templating/Helper/SecurityHelper.php +++ b/src/Symfony/Bundle/SecurityBundle/Templating/Helper/SecurityHelper.php @@ -11,6 +11,8 @@ namespace Symfony\Bundle\SecurityBundle\Templating\Helper; +@trigger_error('The '.SecurityHelper::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED); + use Symfony\Component\Security\Acl\Voter\FieldVote; use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; use Symfony\Component\Templating\Helper\Helper; @@ -19,6 +21,8 @@ * SecurityHelper provides read-only access to the security checker. * * @author Fabien Potencier + * + * @deprecated since version 4.3, to be removed in 5.0; use Twig instead. */ class SecurityHelper extends Helper { diff --git a/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php b/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php index 0f8b8b2720f74..1757a5997ced1 100644 --- a/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php +++ b/src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php @@ -11,6 +11,8 @@ namespace Symfony\Bundle\TwigBundle\Loader; +@trigger_error('The '.FilesystemLoader::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig notation for templates instead.', E_USER_DEPRECATED); + use Symfony\Component\Config\FileLocatorInterface; use Symfony\Component\Templating\TemplateNameParserInterface; use Symfony\Component\Templating\TemplateReferenceInterface; @@ -22,6 +24,8 @@ * to work with the Symfony paths and template references. * * @author Fabien Potencier + * + * @deprecated since version 4.3, to be removed in 5.0; use Twig notation for templates instead. */ class FilesystemLoader extends BaseFilesystemLoader { diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php index 0a227930bd1ef..48077f89aaf92 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php @@ -280,6 +280,9 @@ public function stopwatchExtensionAvailabilityProvider() ]; } + /** + * @group legacy + */ public function testRuntimeLoader() { $container = $this->createContainer(); diff --git a/src/Symfony/Component/Form/Extension/Templating/TemplatingExtension.php b/src/Symfony/Component/Form/Extension/Templating/TemplatingExtension.php index 84dcb1eda9f26..a510752e11914 100644 --- a/src/Symfony/Component/Form/Extension/Templating/TemplatingExtension.php +++ b/src/Symfony/Component/Form/Extension/Templating/TemplatingExtension.php @@ -11,6 +11,8 @@ namespace Symfony\Component\Form\Extension\Templating; +@trigger_error('The '.TemplatingExtension::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED); + use Symfony\Bundle\FrameworkBundle\Templating\Helper\FormHelper; use Symfony\Component\Form\AbstractExtension; use Symfony\Component\Form\FormRenderer; @@ -21,6 +23,8 @@ * Integrates the Templating component with the Form library. * * @author Bernhard Schussek + * + * @deprecated since version 4.3, to be removed in 5.0; use Twig instead. */ class TemplatingExtension extends AbstractExtension { diff --git a/src/Symfony/Component/Form/Extension/Templating/TemplatingRendererEngine.php b/src/Symfony/Component/Form/Extension/Templating/TemplatingRendererEngine.php index 4805a66bba83d..1316e6a165a6d 100644 --- a/src/Symfony/Component/Form/Extension/Templating/TemplatingRendererEngine.php +++ b/src/Symfony/Component/Form/Extension/Templating/TemplatingRendererEngine.php @@ -11,12 +11,16 @@ namespace Symfony\Component\Form\Extension\Templating; +@trigger_error('The '.TemplatingRendererEngine::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED); + use Symfony\Component\Form\AbstractRendererEngine; use Symfony\Component\Form\FormView; use Symfony\Component\Templating\EngineInterface; /** * @author Bernhard Schussek + * + * @deprecated since version 4.3, to be removed in 5.0; use Twig instead. */ class TemplatingRendererEngine extends AbstractRendererEngine { diff --git a/src/Symfony/Component/Form/Forms.php b/src/Symfony/Component/Form/Forms.php index a67c436fe01f2..7ea5ca8235721 100644 --- a/src/Symfony/Component/Form/Forms.php +++ b/src/Symfony/Component/Form/Forms.php @@ -60,30 +60,6 @@ * ->addExtension(new ValidatorExtension($validator)) * ->getFormFactory(); * - * Support for the Templating component is provided by TemplatingExtension. - * This extension needs a PhpEngine object for rendering forms. As second - * argument you should pass the names of the default themes. Here is an - * example for using the default layout with "
" tags: - * - * use Symfony\Component\Form\Extension\Templating\TemplatingExtension; - * - * $formFactory = Forms::createFormFactoryBuilder() - * ->addExtension(new TemplatingExtension($engine, null, [ - * 'FrameworkBundle:Form', - * ])) - * ->getFormFactory(); - * - * The next example shows how to include the "" layout: - * - * use Symfony\Component\Form\Extension\Templating\TemplatingExtension; - * - * $formFactory = Forms::createFormFactoryBuilder() - * ->addExtension(new TemplatingExtension($engine, null, [ - * 'FrameworkBundle:Form', - * 'FrameworkBundle:FormTable', - * ])) - * ->getFormFactory(); - * * @author Bernhard Schussek */ final class Forms diff --git a/src/Symfony/Component/Form/composer.json b/src/Symfony/Component/Form/composer.json index fd39d77edc19e..bb3d43077ec3a 100644 --- a/src/Symfony/Component/Form/composer.json +++ b/src/Symfony/Component/Form/composer.json @@ -48,8 +48,7 @@ "suggest": { "symfony/validator": "For form validation.", "symfony/security-csrf": "For protecting forms against CSRF attacks.", - "symfony/twig-bridge": "For templating with Twig.", - "symfony/framework-bundle": "For templating with PHP." + "symfony/twig-bridge": "For templating with Twig." }, "autoload": { "psr-4": { "Symfony\\Component\\Form\\": "" }, diff --git a/src/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php b/src/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php index 7b8e7619223bd..9a700a9b1158b 100644 --- a/src/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php +++ b/src/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php @@ -59,6 +59,10 @@ public function setTemplating($templating) throw new \InvalidArgumentException('The hinclude rendering strategy needs an instance of Twig\Environment or Symfony\Component\Templating\EngineInterface'); } + if ($templating instanceof EngineInterface) { + @trigger_error(sprintf('Using a "%s" instance for "%s" is deprecated since version 4.3; use a \Twig\Environment instance instead.', EngineInterface::class, __CLASS__), E_USER_DEPRECATED); + } + $this->templating = $templating; } diff --git a/src/Symfony/Component/HttpKernel/Tests/Fragment/HIncludeFragmentRendererTest.php b/src/Symfony/Component/HttpKernel/Tests/Fragment/HIncludeFragmentRendererTest.php index 6125d95ff4ca8..f80f5f811a1b6 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Fragment/HIncludeFragmentRendererTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Fragment/HIncludeFragmentRendererTest.php @@ -16,6 +16,8 @@ use Symfony\Component\HttpKernel\Controller\ControllerReference; use Symfony\Component\HttpKernel\Fragment\HIncludeFragmentRenderer; use Symfony\Component\HttpKernel\UriSigner; +use Twig\Environment; +use Twig\Loader\ArrayLoader; class HIncludeFragmentRendererTest extends TestCase { @@ -74,29 +76,26 @@ public function testRenderWithAttributesOptions() $this->assertEquals('default', $strategy->render('/foo', Request::create('/'), ['default' => 'default', 'id' => 'bar', 'attributes' => ['p1' => 'v1', 'p2' => 'v2']])->getContent()); } - public function testRenderWithDefaultText() + public function testRenderWithTwigAndDefaultText() { - $engine = $this->getMockBuilder('Symfony\\Component\\Templating\\EngineInterface')->getMock(); - $engine->expects($this->once()) - ->method('exists') - ->with('default') - ->willThrowException(new \InvalidArgumentException()); - - // only default - $strategy = new HIncludeFragmentRenderer($engine); - $this->assertEquals('default', $strategy->render('/foo', Request::create('/'), ['default' => 'default'])->getContent()); + $twig = new Environment($loader = new ArrayLoader()); + $strategy = new HIncludeFragmentRenderer($twig); + $this->assertEquals('loading...', $strategy->render('/foo', Request::create('/'), ['default' => 'loading...'])->getContent()); } - public function testRenderWithEngineAndDefaultText() + /** + * @group legacy + */ + public function testRenderWithDefaultTextLegacy() { $engine = $this->getMockBuilder('Symfony\\Component\\Templating\\EngineInterface')->getMock(); $engine->expects($this->once()) ->method('exists') - ->with('loading...') - ->willThrowException(new \RuntimeException()); + ->with('default') + ->willThrowException(new \InvalidArgumentException()); // only default $strategy = new HIncludeFragmentRenderer($engine); - $this->assertEquals('loading...', $strategy->render('/foo', Request::create('/'), ['default' => 'loading...'])->getContent()); + $this->assertEquals('default', $strategy->render('/foo', Request::create('/'), ['default' => 'default'])->getContent()); } } diff --git a/src/Symfony/Component/HttpKernel/composer.json b/src/Symfony/Component/HttpKernel/composer.json index 7cae1e74845fd..998f14f6e6f1b 100644 --- a/src/Symfony/Component/HttpKernel/composer.json +++ b/src/Symfony/Component/HttpKernel/composer.json @@ -39,7 +39,8 @@ "symfony/templating": "~3.4|~4.0", "symfony/translation": "~4.2", "symfony/var-dumper": "^4.1.1", - "psr/cache": "~1.0" + "psr/cache": "~1.0", + "twig/twig": "^1.34|^2.4" }, "provide": { "psr/log-implementation": "1.0"