diff --git a/src/Symfony/Bridge/Twig/Tests/TwigEngineTest.php b/src/Symfony/Bridge/Twig/Tests/TwigEngineTest.php index ab932eebc3..89eba52167 100644 --- a/src/Symfony/Bridge/Twig/Tests/TwigEngineTest.php +++ b/src/Symfony/Bridge/Twig/Tests/TwigEngineTest.php @@ -17,6 +17,9 @@ use Symfony\Component\Templating\TemplateReference; 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 4789f3f4d6..266d824bb4 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 @@ use Twig\Template; * 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 27c103e26c..6e5a11cade 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 @@ use Symfony\Component\Templating\TemplateReferenceInterface; * 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 433ed8f548..f5ed025fac 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 6662a1808d..9db00d828b 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 @@ use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmer; * 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 0650fea5ca..e32f7b6e25 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerTrait.php +++ b/src/Symfony/Bundle/FrameworkBundle/Controller/ControllerTrait.php @@ -206,6 +206,8 @@ trait ControllerTrait 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 @@ trait ControllerTrait 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 @@ trait ControllerTrait 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 4eff0b6c8e..be7418d909 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\ContainerBuilder; 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 @@ class TemplatingPass implements CompilerPassInterface 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 ef6a2147e3..870c499aaf 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -264,6 +264,8 @@ class FrameworkExtension extends Extension } 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 83c904f16f..b6b70be999 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 f6cfd4ae68..3dd7b84c12 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 06ab2f41fc..440b9a5d23 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 f40760fc91..bd292e4681 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 @@ use Symfony\Component\Templating\DelegatingEngine as BaseDelegatingEngine; * 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 0b3a8b3200..2539980b9d 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 @@ use Symfony\Component\Templating\EngineInterface as BaseEngineInterface; * 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 4e07b9b5b8..2981eb6642 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 @@ use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; * 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 70e5a314bb..8a054162fb 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 @@ use Symfony\Component\Templating\Helper\Helper; * 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 072b6e7fc9..ff237d6a97 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 @@ use Symfony\Component\Templating\Helper\Helper; * 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 56fcc24cf0..1d8885ba40 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 dd1d14149a..0956d31ada 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 @@ use Symfony\Component\Templating\Helper\Helper; * * @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 3beaaada2a..351ed712c4 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 @@ use Symfony\Component\Templating\Helper\Helper; * 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 f242479086..0854fe3f04 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 @@ use Symfony\Component\Templating\Helper\Helper; * 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 072c1d3d21..86c0fcda1b 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 @@ use Symfony\Component\Templating\Helper\Helper; * 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 1b16d47dbb..9ec4df47a1 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 @@ use Symfony\Component\Templating\Helper\Helper; * 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 5debaae9d6..b86c0da666 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 @@ use Symfony\Contracts\Translation\TranslatorTrait; /** * @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 4edceed8ab..52edeb8619 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 @@ use Symfony\Component\Templating\TemplateReferenceInterface; * 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 4e4743dcc5..39ebe0e1d3 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 @@ use Symfony\Component\Templating\TemplateReferenceInterface; * 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 ef9c43b8fd..080d0b7815 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 @@ use Symfony\Component\Templating\TemplateNameParserInterface; * 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 b6870334c6..de383461d7 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 @@ use Symfony\Component\Templating\TemplateReferenceInterface; * 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 d1be3e9074..ffa9a923f1 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 @@ use Symfony\Component\Templating\TemplateReferenceInterface; * 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 830942972a..3bc461ebb6 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 783e675f97..faa7c55fae 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 @@ use Symfony\Component\Templating\TemplateNameParserInterface; * 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 94b5432c3a..ad12c38c3e 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\Templating\TemplateFilenameParser; 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 30d0242663..209887696a 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\Bundle\FrameworkBundle\Tests\TestCase; 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 8bd22bed79..179b6edc0c 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTraitTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTraitTest.php @@ -439,6 +439,9 @@ abstract class ControllerTraitTest extends TestCase $this->assertSame(301, $response->getStatusCode()); } + /** + * @group legacy + */ public function testRenderViewTemplating() { $templating = $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Templating\EngineInterface')->getMock(); @@ -453,6 +456,9 @@ abstract class ControllerTraitTest extends TestCase $this->assertEquals('bar', $controller->renderView('foo')); } + /** + * @group legacy + */ public function testRenderTemplating() { $templating = $this->getMockBuilder('Symfony\Bundle\FrameworkBundle\Templating\EngineInterface')->getMock(); @@ -467,6 +473,9 @@ abstract class ControllerTraitTest extends TestCase $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 8684a569a9..e02ba9183f 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 @@ $container->loadFromExtension('framework', [ '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 0000000000..162d09199f --- /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 ed4b14671e..905c187ef8 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 0000000000..192533dbf6 --- /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 0751eb933e..9194911b06 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 0000000000..d307e1609b --- /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 0c0b5cc6c3..0e6eff1e10 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php @@ -533,9 +533,12 @@ abstract class FrameworkExtensionTest extends TestCase $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 @@ abstract class FrameworkExtensionTest extends TestCase $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 @@ abstract class FrameworkExtensionTest extends TestCase $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 43f91f5213..8e582b13a8 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/AutowiringTypesTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/AutowiringTypesTest.php @@ -37,9 +37,12 @@ class AutowiringTypesTest extends WebTestCase $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 a62cdf64df..d9a7b59d46 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 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\Auto 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 @@ class AutowiredServices 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 0000000000..7fc0cdd7b5 --- /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 aa78c87190..8436a3b248 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\ContainerAwareInterface; 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 db550a2312..d3dbeb765b 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 1b47c1100a..93fd9eefac 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 0000000000..765bfa9d70 --- /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 29f1e32ff9..5754ba9693 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 15ff182c6f..50676b6364 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 f7ea83dfa7..16fc81dd26 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 0000000000..be54586434 --- /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 0e89a5b36c..0000000000 --- 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 0000000000..4dea4b360b --- /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 73983e47ce..8d5eb96a53 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/DelegatingEngineTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/DelegatingEngineTest.php @@ -15,6 +15,9 @@ use PHPUnit\Framework\TestCase; 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 d6c6b299eb..984a2388e9 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\Templating\GlobalVariables; 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 83df0640bf..06e87f43f7 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\Package; 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 35dbc03f34..729b01920f 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\Form\Tests\AbstractDivLayoutTest; 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 262421bf34..8e335788ea 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\Form\Tests\AbstractTableLayoutTest; 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 a2068ae757..d29b5c0ff4 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\Bundle\FrameworkBundle\Templating\Helper\RequestHelper; 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 06984095f1..c9521e8e54 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\RequestStack; 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 686c655aac..f5030b4e79 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 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Templating\Helper; 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 3317b15d90..fbe8125b9a 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\Loader\TemplateLocator; 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 9628828afa..47f3f360aa 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\Session; 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 3c44612b87..305be17591 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\TemplateFilenameParser; 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 9b4db5101a..9882fd9a9d 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\Templating\TemplateReference; 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 35561bf52b..179c3b6da0 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateReferenceTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateReferenceTest.php @@ -14,6 +14,9 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Templating; 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 66872049ad..899740169f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/TemplateTest.php @@ -14,6 +14,9 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Templating; 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 bd02809dc0..1347cccf57 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\Templating\TimedPhpEngine; 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 f065dafc66..2a0ba94f87 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/SecurityBundle/DependencyInjection/SecurityExtension.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php index a3d41a70a6..4d74daa4d4 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\Authorization\Voter\VoterInterface; 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 @@ class SecurityExtension extends Extension implements PrependExtensionInterface $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 b2ce15d1b1..b2bafbc605 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 3051ed38dc..30ef9c2829 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 @@ use Symfony\Component\Templating\Helper\Helper; * 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 337748f41b..f6738bd369 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 @@ use Symfony\Component\Templating\Helper\Helper; * 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 0f8b8b2720..1757a5997c 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 @@ use Twig\Loader\FilesystemLoader as BaseFilesystemLoader; * 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 0a227930bd..48077f89aa 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php @@ -280,6 +280,9 @@ class TwigExtensionTest extends TestCase ]; } + /** + * @group legacy + */ public function testRuntimeLoader() { $container = $this->createContainer(); diff --git a/src/Symfony/Bundle/TwigBundle/Tests/Functional/CacheWarmingTest.php b/src/Symfony/Bundle/TwigBundle/Tests/Functional/CacheWarmingTest.php index c5999752d0..ca21df0902 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\Config\Loader\LoaderInterface; 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 39115199e5..b8a4995fcd 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 @@ use Twig\Error\Error; * 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 { diff --git a/src/Symfony/Component/Form/Extension/Templating/TemplatingExtension.php b/src/Symfony/Component/Form/Extension/Templating/TemplatingExtension.php index 84dcb1eda9..a510752e11 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 @@ use Symfony\Component\Templating\PhpEngine; * 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 4805a66bba..1316e6a165 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 a67c436fe0..7ea5ca8235 100644 --- a/src/Symfony/Component/Form/Forms.php +++ b/src/Symfony/Component/Form/Forms.php @@ -60,30 +60,6 @@ use Symfony\Component\Form\Extension\Core\CoreExtension; * ->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 fd39d77edc..bb3d43077e 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 7b8e761922..9a700a9b11 100644 --- a/src/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php +++ b/src/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php @@ -59,6 +59,10 @@ class HIncludeFragmentRenderer extends RoutableFragmentRenderer 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 6125d95ff4..f80f5f811a 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\HttpFoundation\Request; 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,7 +76,17 @@ class HIncludeFragmentRendererTest extends TestCase $this->assertEquals('default', $strategy->render('/foo', Request::create('/'), ['default' => 'default', 'id' => 'bar', 'attributes' => ['p1' => 'v1', 'p2' => 'v2']])->getContent()); } - public function testRenderWithDefaultText() + public function testRenderWithTwigAndDefaultText() + { + $twig = new Environment($loader = new ArrayLoader()); + $strategy = new HIncludeFragmentRenderer($twig); + $this->assertEquals('loading...', $strategy->render('/foo', Request::create('/'), ['default' => 'loading...'])->getContent()); + } + + /** + * @group legacy + */ + public function testRenderWithDefaultTextLegacy() { $engine = $this->getMockBuilder('Symfony\\Component\\Templating\\EngineInterface')->getMock(); $engine->expects($this->once()) @@ -86,17 +98,4 @@ class HIncludeFragmentRendererTest extends TestCase $strategy = new HIncludeFragmentRenderer($engine); $this->assertEquals('default', $strategy->render('/foo', Request::create('/'), ['default' => 'default'])->getContent()); } - - public function testRenderWithEngineAndDefaultText() - { - $engine = $this->getMockBuilder('Symfony\\Component\\Templating\\EngineInterface')->getMock(); - $engine->expects($this->once()) - ->method('exists') - ->with('loading...') - ->willThrowException(new \RuntimeException()); - - // only default - $strategy = new HIncludeFragmentRenderer($engine); - $this->assertEquals('loading...', $strategy->render('/foo', Request::create('/'), ['default' => 'loading...'])->getContent()); - } } diff --git a/src/Symfony/Component/HttpKernel/composer.json b/src/Symfony/Component/HttpKernel/composer.json index 7cae1e7484..998f14f6e6 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"