Skip to content

Commit

Permalink
[FrameworkBundle] Deprecate the Templating component integration
Browse files Browse the repository at this point in the history
  • Loading branch information
dunglas authored and fabpot committed Mar 19, 2019
1 parent bff9e68 commit dbbb32e
Show file tree
Hide file tree
Showing 70 changed files with 357 additions and 77 deletions.
3 changes: 3 additions & 0 deletions src/Symfony/Bridge/Twig/Tests/TwigEngineTest.php
Expand Up @@ -17,6 +17,9 @@
use Twig\Environment;
use Twig\Loader\ArrayLoader;

/**
* @group legacy
*/
class TwigEngineTest extends TestCase
{
public function testExistsWithTemplateInstances()
Expand Down
4 changes: 4 additions & 0 deletions src/Symfony/Bridge/Twig/TwigEngine.php
Expand Up @@ -11,6 +11,8 @@

namespace Symfony\Bridge\Twig;

@trigger_error('The '.TwigEngine::class.' class is deprecated since version 4.1 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;
Expand All @@ -25,6 +27,8 @@
* This engine knows how to render Twig templates.
*
* @author Fabien Potencier <fabien@symfony.com>
*
* @deprecated since version 4.3, to be removed in 5.0. Use Twig instead.
*/
class TwigEngine implements EngineInterface, StreamingEngineInterface
{
Expand Down
Expand Up @@ -11,6 +11,8 @@

namespace Symfony\Bundle\FrameworkBundle\CacheWarmer;

@trigger_error('The '.TemplateFinder::class.' class is deprecated since version 4.1 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;
Expand All @@ -21,6 +23,8 @@
* Finds all the templates.
*
* @author Victor Berchet <victor@suumit.com>
*
* @deprecated since version 4.3, to be removed in 5.0. Use Twig instead.
*/
class TemplateFinder implements TemplateFinderInterface
{
Expand Down
Expand Up @@ -11,10 +11,14 @@

namespace Symfony\Bundle\FrameworkBundle\CacheWarmer;

@trigger_error('The '.TemplateFinderInterface::class.' interface is deprecated since version 4.1 and will be removed in 5.0. Use Twig instead.', E_USER_DEPRECATED);

/**
* Interface for finding all the templates.
*
* @author Victor Berchet <victor@suumit.com>
*
* @deprecated since version 4.3, to be removed in 5.0. Use Twig instead.
*/
interface TemplateFinderInterface
{
Expand Down
Expand Up @@ -11,6 +11,8 @@

namespace Symfony\Bundle\FrameworkBundle\CacheWarmer;

@trigger_error('The '.TemplatePathsCacheWarmer::class.' class is deprecated since version 4.1 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;
Expand All @@ -19,6 +21,8 @@
* Computes the association between template names and their paths on the disk.
*
* @author Fabien Potencier <fabien@symfony.com>
*
* @deprecated since version 4.3, to be removed in 5.0. Use Twig instead.
*/
class TemplatePathsCacheWarmer extends CacheWarmer
{
Expand Down
Expand Up @@ -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.1 and will be removed in 5.0. Use Twig instead.', E_USER_DEPRECATED);

return $this->container->get('templating')->render($view, $parameters);
}

Expand All @@ -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.1 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);
Expand All @@ -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.1 and will be removed in 5.0. Use Twig instead.', E_USER_DEPRECATED);

$templating = $this->container->get('templating');

$callback = function () use ($templating, $view, $parameters) {
Expand Down
Expand Up @@ -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)
Expand All @@ -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.1 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);
Expand Down
Expand Up @@ -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.1 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".');
}
Expand Down
15 changes: 15 additions & 0 deletions src/Symfony/Bundle/FrameworkBundle/Resources/config/templating.xml
Expand Up @@ -10,41 +10,56 @@
<service id="templating.engine.delegating" class="Symfony\Bundle\FrameworkBundle\Templating\DelegatingEngine">
<argument type="service" id="service_container" />
<argument type="collection" /> <!-- engines -->

<deprecated>The "%service_id%" service is deprecated since Symfony 4.1 and will be removed in 5.0.</deprecated>
</service>

<service id="templating.name_parser" class="Symfony\Bundle\FrameworkBundle\Templating\TemplateNameParser">
<argument type="service" id="kernel" />

<deprecated>The "%service_id%" service is deprecated since Symfony 4.1 and will be removed in 5.0.</deprecated>
</service>

<service id="templating.filename_parser" class="Symfony\Bundle\FrameworkBundle\Templating\TemplateFilenameParser" />

<service id="templating.locator" class="Symfony\Bundle\FrameworkBundle\Templating\Loader\TemplateLocator">
<argument type="service" id="file_locator" />
<argument>%kernel.cache_dir%</argument>

<deprecated>The "%service_id%" service is deprecated since Symfony 4.1 and will be removed in 5.0.</deprecated>
</service>

<service id="templating.finder" class="Symfony\Bundle\FrameworkBundle\CacheWarmer\TemplateFinder">
<argument type="service" id="kernel" />
<argument type="service" id="templating.filename_parser" />
<argument>%kernel.root_dir%/Resources</argument>

<deprecated>The "%service_id%" service is deprecated since Symfony 4.1 and will be removed in 5.0.</deprecated>
</service>

<service id="templating.cache_warmer.template_paths" class="Symfony\Bundle\FrameworkBundle\CacheWarmer\TemplatePathsCacheWarmer">
<tag name="kernel.cache_warmer" priority="20" />
<argument type="service" id="templating.finder" />
<argument type="service" id="templating.locator" />

<deprecated>The "%service_id%" service is deprecated since Symfony 4.1 and will be removed in 5.0.</deprecated>
</service>

<service id="templating.loader.filesystem" class="Symfony\Bundle\FrameworkBundle\Templating\Loader\FilesystemLoader">
<argument type="service" id="templating.locator" />

<deprecated>The "%service_id%" service is deprecated since Symfony 4.1 and will be removed in 5.0.</deprecated>
</service>

<service id="templating.loader.cache" class="Symfony\Component\Templating\Loader\CacheLoader">
<argument type="service" id="templating.loader.wrapped" />
<argument>%templating.loader.cache.path%</argument>

<deprecated>The "%service_id%" service is deprecated since Symfony 4.1 and will be removed in 5.0.</deprecated>
</service>

<service id="templating.loader.chain" class="Symfony\Component\Templating\Loader\ChainLoader">
<deprecated>The "%service_id%" service is deprecated since Symfony 4.1 and will be removed in 5.0.</deprecated>
</service>

<service id="templating.loader" alias="templating.loader.filesystem" public="true" />
Expand Down
Expand Up @@ -14,6 +14,8 @@
<argument type="service" id="debug.stopwatch" />
<argument type="service" id="templating.globals" />
<call method="setCharset"><argument>%kernel.charset%</argument></call>

<deprecated>The "%service_id%" service is deprecated since Symfony 4.1 and will be removed in 5.0.</deprecated>
</service>
</services>
</container>
Expand Up @@ -13,6 +13,8 @@
<argument type="service" id="templating.loader" />
<argument type="service" id="templating.globals" />
<call method="setCharset"><argument>%kernel.charset%</argument></call>

<deprecated>The "%service_id%" service is deprecated since Symfony 4.1 and will be removed in 5.0.</deprecated>
</service>

<service id="templating.engine.php.helpers_locator">
Expand All @@ -22,67 +24,93 @@

<service id="templating.helper.slots" class="Symfony\Component\Templating\Helper\SlotsHelper">
<tag name="templating.helper" alias="slots" />

<deprecated>The "%service_id%" service is deprecated since Symfony 4.1 and will be removed in 5.0.</deprecated>
</service>

<service id="templating.helper.request" class="Symfony\Bundle\FrameworkBundle\Templating\Helper\RequestHelper">
<tag name="templating.helper" alias="request" />
<argument type="service" id="request_stack" />

<deprecated>The "%service_id%" service is deprecated since Symfony 4.1 and will be removed in 5.0.</deprecated>
</service>

<service id="templating.helper.session" class="Symfony\Bundle\FrameworkBundle\Templating\Helper\SessionHelper">
<tag name="templating.helper" alias="session" />
<argument type="service" id="request_stack" />

<deprecated>The "%service_id%" service is deprecated since Symfony 4.1 and will be removed in 5.0.</deprecated>
</service>

<service id="templating.helper.router" class="Symfony\Bundle\FrameworkBundle\Templating\Helper\RouterHelper">
<tag name="templating.helper" alias="router" />
<argument type="service" id="router" />

<deprecated>The "%service_id%" service is deprecated since Symfony 4.1 and will be removed in 5.0.</deprecated>
</service>

<service id="templating.helper.assets" class="Symfony\Bundle\FrameworkBundle\Templating\Helper\AssetsHelper">
<tag name="templating.helper" alias="assets" />
<argument /> <!-- packages -->

<deprecated>The "%service_id%" service is deprecated since Symfony 4.1 and will be removed in 5.0.</deprecated>
</service>

<service id="templating.helper.actions" class="Symfony\Bundle\FrameworkBundle\Templating\Helper\ActionsHelper">
<tag name="templating.helper" alias="actions" />
<argument type="service" id="fragment.handler" />

<deprecated>The "%service_id%" service is deprecated since Symfony 4.1 and will be removed in 5.0.</deprecated>
</service>

<service id="templating.helper.code" class="Symfony\Bundle\FrameworkBundle\Templating\Helper\CodeHelper">
<tag name="templating.helper" alias="code" />
<argument type="service" id="debug.file_link_formatter"></argument>
<argument>%kernel.project_dir%</argument>
<argument>%kernel.charset%</argument>

<deprecated>The "%service_id%" service is deprecated since Symfony 4.1 and will be removed in 5.0.</deprecated>
</service>

<service id="templating.helper.translator" class="Symfony\Bundle\FrameworkBundle\Templating\Helper\TranslatorHelper">
<tag name="templating.helper" alias="translator" />
<argument type="service" id="translator" on-invalid="null" />

<deprecated>The "%service_id%" service is deprecated since Symfony 4.1 and will be removed in 5.0.</deprecated>
</service>

<service id="templating.helper.form" class="Symfony\Bundle\FrameworkBundle\Templating\Helper\FormHelper">
<tag name="templating.helper" alias="form" />
<argument type="service" id="templating.form.renderer" />

<deprecated>The "%service_id%" service is deprecated since Symfony 4.1 and will be removed in 5.0.</deprecated>
</service>

<service id="templating.helper.stopwatch" class="Symfony\Bundle\FrameworkBundle\Templating\Helper\StopwatchHelper">
<tag name="templating.helper" alias="stopwatch" />
<argument type="service" id="debug.stopwatch" on-invalid="ignore" />

<deprecated>The "%service_id%" service is deprecated since Symfony 4.1 and will be removed in 5.0.</deprecated>
</service>

<service id="templating.form.engine" class="Symfony\Component\Form\Extension\Templating\TemplatingRendererEngine">
<argument type="service" id="templating.engine.php" />
<argument>%templating.helper.form.resources%</argument>

<deprecated>The "%service_id%" service is deprecated since Symfony 4.1 and will be removed in 5.0.</deprecated>
</service>

<service id="templating.form.renderer" class="Symfony\Component\Form\FormRenderer">
<argument type="service" id="templating.form.engine" />
<argument type="service" id="security.csrf.token_manager" on-invalid="null" />

<deprecated>The "%service_id%" service is deprecated since Symfony 4.1 and will be removed in 5.0.</deprecated>
</service>

<service id="templating.globals" class="Symfony\Bundle\FrameworkBundle\Templating\GlobalVariables">
<argument type="service" id="service_container" />

<deprecated>The "%service_id%" service is deprecated since Symfony 4.1 and will be removed in 5.0.</deprecated>
</service>
</services>
</container>
Expand Up @@ -11,6 +11,8 @@

namespace Symfony\Bundle\FrameworkBundle\Templating;

@trigger_error('The '.DelegatingEngine::class.' class is deprecated since version 4.1 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;
Expand All @@ -19,6 +21,8 @@
* DelegatingEngine selects an engine for a given template.
*
* @author Fabien Potencier <fabien@symfony.com>
*
* @deprecated since version 4.3, to be removed in 5.0. Use Twig instead.
*/
class DelegatingEngine extends BaseDelegatingEngine implements EngineInterface
{
Expand Down
Expand Up @@ -11,13 +11,17 @@

namespace Symfony\Bundle\FrameworkBundle\Templating;

@trigger_error('The '.EngineInterface::class.' interface is deprecated since version 4.1 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;

/**
* EngineInterface is the interface each engine must implement.
*
* @author Fabien Potencier <fabien@symfony.com>
*
* @deprecated since version 4.3, to be removed in 5.0. Use Twig instead.
*/
interface EngineInterface extends BaseEngineInterface
{
Expand Down
Expand Up @@ -11,6 +11,8 @@

namespace Symfony\Bundle\FrameworkBundle\Templating;

@trigger_error('The '.GlobalVariables::class.' class is deprecated since version 4.1 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;
Expand All @@ -20,6 +22,8 @@
* GlobalVariables is the entry point for Symfony global variables in PHP templates.
*
* @author Fabien Potencier <fabien@symfony.com>
*
* @deprecated since version 4.3, to be removed in 5.0. Use Twig instead.
*/
class GlobalVariables
{
Expand Down
Expand Up @@ -11,6 +11,8 @@

namespace Symfony\Bundle\FrameworkBundle\Templating\Helper;

@trigger_error('The '.ActionsHelper::class.' class is deprecated since version 4.1 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;
Expand All @@ -19,6 +21,8 @@
* ActionsHelper manages action inclusions.
*
* @author Fabien Potencier <fabien@symfony.com>
*
* @deprecated since version 4.3, to be removed in 5.0. Use Twig instead.
*/
class ActionsHelper extends Helper
{
Expand Down
Expand Up @@ -11,13 +11,17 @@

namespace Symfony\Bundle\FrameworkBundle\Templating\Helper;

@trigger_error('The '.AssetsHelper::class.' class is deprecated since version 4.1 and will be removed in 5.0. Use Twig instead.', E_USER_DEPRECATED);

use Symfony\Component\Asset\Packages;
use Symfony\Component\Templating\Helper\Helper;

/**
* AssetsHelper helps manage asset URLs.
*
* @author Fabien Potencier <fabien@symfony.com>
*
* @deprecated since version 4.3, to be removed in 5.0. Use Twig instead.
*/
class AssetsHelper extends Helper
{
Expand Down

0 comments on commit dbbb32e

Please sign in to comment.