[FrameworkBundle] Deprecate the Templating component integration

This commit is contained in:
Kévin Dunglas 2016-12-23 15:53:44 +01:00 committed by Fabien Potencier
parent b315c638d5
commit 224c891e10
71 changed files with 365 additions and 73 deletions

View File

@ -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()

View File

@ -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 <fabien@symfony.com>
*
* @deprecated since version 4.3, to be removed in 5.0; use Twig instead.
*/
class TwigEngine implements EngineInterface, StreamingEngineInterface
{

View File

@ -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 <victor@suumit.com>
*
* @deprecated since version 4.3, to be removed in 5.0; use Twig instead.
*/
class TemplateFinder implements TemplateFinderInterface
{

View File

@ -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 <victor@suumit.com>
*
* @deprecated since version 4.3, to be removed in 5.0; use Twig instead.
*/
interface TemplateFinderInterface
{

View File

@ -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 <fabien@symfony.com>
*
* @deprecated since version 4.3, to be removed in 5.0; use Twig instead.
*/
class TemplatePathsCacheWarmer extends CacheWarmer
{

View File

@ -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) {

View File

@ -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);

View File

@ -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".');
}

View File

@ -10,10 +10,14 @@
<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.3 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.3 and will be removed in 5.0.</deprecated>
</service>
<service id="templating.filename_parser" class="Symfony\Bundle\FrameworkBundle\Templating\TemplateFilenameParser" />
@ -21,30 +25,41 @@
<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.3 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.3 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.3 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.3 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.3 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.3 and will be removed in 5.0.</deprecated>
</service>
<service id="templating.loader" alias="templating.loader.filesystem" public="true" />

View File

@ -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.3 and will be removed in 5.0.</deprecated>
</service>
</services>
</container>

View File

@ -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.3 and will be removed in 5.0.</deprecated>
</service>
<service id="templating.engine.php.helpers_locator">
@ -22,31 +24,43 @@
<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.3 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.3 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.3 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.3 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.3 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.3 and will be removed in 5.0.</deprecated>
</service>
<service id="templating.helper.code" class="Symfony\Bundle\FrameworkBundle\Templating\Helper\CodeHelper">
@ -54,35 +68,49 @@
<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.3 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.3 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.3 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.3 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.3 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.3 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.3 and will be removed in 5.0.</deprecated>
</service>
</services>
</container>

View File

@ -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 <fabien@symfony.com>
*
* @deprecated since version 4.3, to be removed in 5.0; use Twig instead.
*/
class DelegatingEngine extends BaseDelegatingEngine implements EngineInterface
{

View File

@ -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 <fabien@symfony.com>
*
* @deprecated since version 4.3, to be removed in 5.0; use Twig instead.
*/
interface EngineInterface extends BaseEngineInterface
{

View File

@ -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 <fabien@symfony.com>
*
* @deprecated since version 4.3, to be removed in 5.0; use Twig instead.
*/
class GlobalVariables
{

View File

@ -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 <fabien@symfony.com>
*
* @deprecated since version 4.3, to be removed in 5.0; use Twig instead.
*/
class ActionsHelper extends Helper
{

View File

@ -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 <fabien@symfony.com>
*
* @deprecated since version 4.3, to be removed in 5.0; use Twig instead.
*/
class AssetsHelper extends Helper
{

View File

@ -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 <fabien@symfony.com>
*
* @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
{

View File

@ -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 <fabien@symfony.com>
* @author Bernhard Schussek <bschussek@gmail.com>
*
* @deprecated since version 4.3, to be removed in 5.0; use Twig instead.
*/
class FormHelper extends Helper
{

View File

@ -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 <fabien@symfony.com>
*
* @deprecated since version 4.3, to be removed in 5.0; use Twig instead.
*/
class RequestHelper extends Helper
{

View File

@ -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 <fabien@symfony.com>
*
* @deprecated since version 4.3, to be removed in 5.0; use Twig instead.
*/
class RouterHelper extends Helper
{

View File

@ -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 <fabien@symfony.com>
*
* @deprecated since version 4.3, to be removed in 5.0; use Twig instead.
*/
class SessionHelper extends Helper
{

View File

@ -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 <wouter@wouterj.nl>
*
* @deprecated since version 4.3, to be removed in 5.0; use Twig instead.
*/
class StopwatchHelper extends Helper
{

View File

@ -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 <fabien@symfony.com>
*
* @deprecated since version 4.3, to be removed in 5.0; use Twig instead.
*/
class TranslatorHelper extends Helper
{

View File

@ -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 <fabien@symfony.com>
*
* @deprecated since version 4.3, to be removed in 5.0; use Twig instead.
*/
class FilesystemLoader implements LoaderInterface
{

View File

@ -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 <fabien@symfony.com>
*
* @deprecated since version 4.3, to be removed in 5.0; use Twig instead.
*/
class TemplateLocator implements FileLocatorInterface
{

View File

@ -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 <fabien@symfony.com>
*
* @deprecated since version 4.3, to be removed in 5.0; use Twig instead.
*/
class PhpEngine extends BasePhpEngine implements EngineInterface
{

View File

@ -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 <fabien@symfony.com>
*
* @deprecated since version 4.3, to be removed in 5.0; use Twig instead.
*/
class TemplateFilenameParser implements TemplateNameParserInterface
{

View File

@ -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 <fabien@symfony.com>
*
* @deprecated since version 4.3, to be removed in 5.0; use Twig instead.
*/
class TemplateNameParser extends BaseTemplateNameParser
{

View File

@ -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 <victor@suumit.com>
*
* @deprecated since version 4.3, to be removed in 5.0; use Twig instead.
*/
class TemplateReference extends BaseTemplateReference
{

View File

@ -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 <fabien@symfony.com>
*
* @deprecated since version 4.3, to be removed in 5.0; use Twig instead.
*/
class TimedPhpEngine extends PhpEngine
{

View File

@ -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()

View File

@ -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 */

View File

@ -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();

View File

@ -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',
],

View File

@ -0,0 +1,14 @@
<?php
$container->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,
));

View File

@ -25,16 +25,6 @@
<framework:mime-type>application/pdf</framework:mime-type>
</framework:format>
</framework:request>
<framework:templating cache="/path/to/cache" hinclude-default-template="global_hinclude_template">
<framework:loader>loader.foo</framework:loader>
<framework:loader>loader.bar</framework:loader>
<framework:engine>php</framework:engine>
<framework:engine>twig</framework:engine>
<framework:form>
<framework:resource>theme1</framework:resource>
<framework:resource>theme2</framework:resource>
</framework:form>
</framework:templating>
<framework:assets version="v1" />
<framework:translator enabled="true" fallback="fr" logging="true">
<framework:path>%kernel.project_dir%/Fixtures/translations</framework:path>

View File

@ -0,0 +1,22 @@
<?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:framework="http://symfony.com/schema/dic/symfony"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
<framework:config secret="s3cr3t">
<framework:assets />
<framework:templating cache="/path/to/cache" hinclude-default-template="global_hinclude_template">
<framework:loader>loader.foo</framework:loader>
<framework:loader>loader.bar</framework:loader>
<framework:engine>php</framework:engine>
<framework:engine>twig</framework:engine>
<framework:form>
<framework:resource>theme1</framework:resource>
<framework:resource>theme2</framework:resource>
</framework:form>
</framework:templating>
</framework:config>
</container>

View File

@ -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:

View File

@ -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: ~

View File

@ -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');

View File

@ -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());

View File

@ -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;

View File

@ -0,0 +1,31 @@
<?php
namespace Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\AutowiringTypes;
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface as FrameworkBundleEngineInterface;
use Symfony\Component\Templating\EngineInterface;
/**
* @author Kévin Dunglas <dunglas@gmail.com>
*/
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;
}
}

View File

@ -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)

View File

@ -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(<<<TXT
bar txt
--
html
--
es
--
fr
TXT
, $client->getResponse()->getContent());
}
public function getConfigs()

View File

@ -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']

View File

@ -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']

View File

@ -9,9 +9,6 @@ framework:
router: true
session: true
request: true
templating:
enabled: true
engines: ['php']
assets: true
translator: true
validation: true

View File

@ -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(),
];

View File

@ -1,7 +1,9 @@
imports:
- { resource: ../config/default.yml }
- { resource: services.yml }
framework:
fragments: ~
templating:
engines: ['php']
twig:
strict_variables: '%kernel.debug%'

View File

@ -0,0 +1,6 @@
services:
_defaults:
public: true
Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\Controller\FragmentController:
tags: ['controller.service_arguments']

View File

@ -1,14 +0,0 @@
<?php echo $this->get('actions')->render($this->get('actions')->controller('Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\Controller\FragmentController::inlinedAction', [
'options' => [
'bar' => $bar,
'eleven' => 11,
],
]));
?>--<?php
echo $this->get('actions')->render($this->get('actions')->controller('Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\Controller\FragmentController::customformatAction', ['_format' => 'html']));
?>--<?php
echo $this->get('actions')->render($this->get('actions')->controller('Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\Controller\FragmentController::customlocaleAction', ['_locale' => 'es']));
?>--<?php
$app->getRequest()->setLocale('fr');
echo $this->get('actions')->render($this->get('actions')->controller('Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\Controller\FragmentController::forwardlocaleAction'));
?>

View File

@ -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')) -}}

View File

@ -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()

View File

@ -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;

View File

@ -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;

View File

@ -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
{
/**

View File

@ -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
{
/**

View File

@ -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;

View File

@ -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;

View File

@ -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()

View File

@ -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()

View File

@ -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()

View File

@ -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;

View File

@ -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;

View File

@ -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()

View File

@ -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
{
/**

View File

@ -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()

View File

@ -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",

View File

@ -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()

View File

@ -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 <fabien@symfony.com>
*
* @deprecated since version 4.3, to be removed in 5.0; use Twig instead.
*/
class TwigEngine extends BaseEngine implements EngineInterface
{