From 6148652d05efab79ff891d29a403fadd8ec624c1 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 12 Jan 2015 14:49:09 +0100 Subject: [PATCH] [FrameworkBundle] removed obsolete ContainerAwareHIncludeFragmentRenderer class --- .../DependencyInjection/FrameworkExtension.php | 5 +++++ .../ContainerAwareHIncludeFragmentRenderer.php | 4 ++++ .../Resources/config/fragment_renderer.xml | 5 ++--- ...ainerAwareHIncludeFragmentRendererTest.php} | 4 +++- .../Controller/FragmentController.php | 18 +----------------- .../Functional/app/Resources/fragment.html.php | 14 ++++++++++++++ 6 files changed, 29 insertions(+), 21 deletions(-) rename src/Symfony/Bundle/FrameworkBundle/Tests/Fragment/{ContainerAwareHIncludeFragmentRendererTest.php => LegacyContainerAwareHIncludeFragmentRendererTest.php} (86%) create mode 100644 src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Resources/fragment.html.php diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index 0adf3cb6f8..2a67e53d8a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -539,6 +539,11 @@ class FrameworkExtension extends Extension $container->setAlias('templating', 'templating.engine.delegating'); } + $container->getDefinition('fragment.renderer.hinclude') + ->addTag('kernel.fragment_renderer', array('alias' => 'hinclude')) + ->replaceArgument(0, new Reference('templating')) + ; + // configure the PHP engine if needed if (in_array('php', $config['engines'], true)) { $loader->load('templating_php.xml'); diff --git a/src/Symfony/Bundle/FrameworkBundle/Fragment/ContainerAwareHIncludeFragmentRenderer.php b/src/Symfony/Bundle/FrameworkBundle/Fragment/ContainerAwareHIncludeFragmentRenderer.php index 698d979082..9772912d74 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Fragment/ContainerAwareHIncludeFragmentRenderer.php +++ b/src/Symfony/Bundle/FrameworkBundle/Fragment/ContainerAwareHIncludeFragmentRenderer.php @@ -11,6 +11,8 @@ namespace Symfony\Bundle\FrameworkBundle\Fragment; +trigger_error('The '.__NAMESPACE__.'\ContainerAwareHIncludeFragmentRenderer class is deprecated since version 2.7 and will be removed in 3.0. Use Symfony\Bundle\FrameworkBundle\Fragment\HIncludeFragmentRenderer instead.', E_USER_DEPRECATED); + use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\UriSigner; @@ -20,6 +22,8 @@ use Symfony\Component\HttpKernel\Fragment\HIncludeFragmentRenderer; * Implements the Hinclude rendering strategy. * * @author Fabien Potencier + * + * @deprecated since version 2.7, to be removed in 3.0. Use Symfony\Bundle\FrameworkBundle\Fragment\HIncludeFragmentRenderer instead. */ class ContainerAwareHIncludeFragmentRenderer extends HIncludeFragmentRenderer { diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/fragment_renderer.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/fragment_renderer.xml index 7ac0d68dc9..d3687da13a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/fragment_renderer.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/fragment_renderer.xml @@ -7,7 +7,7 @@ Symfony\Component\HttpKernel\DependencyInjection\LazyLoadingFragmentHandler Symfony\Component\HttpKernel\Fragment\InlineFragmentRenderer - Symfony\Bundle\FrameworkBundle\Fragment\ContainerAwareHIncludeFragmentRenderer + Symfony\Component\HttpKernel\Fragment\HIncludeFragmentRenderer Symfony\Component\HttpKernel\Fragment\EsiFragmentRenderer /_fragment @@ -28,8 +28,7 @@ - - + %fragment.renderer.hinclude.global_template% %fragment.path% diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Fragment/ContainerAwareHIncludeFragmentRendererTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Fragment/LegacyContainerAwareHIncludeFragmentRendererTest.php similarity index 86% rename from src/Symfony/Bundle/FrameworkBundle/Tests/Fragment/ContainerAwareHIncludeFragmentRendererTest.php rename to src/Symfony/Bundle/FrameworkBundle/Tests/Fragment/LegacyContainerAwareHIncludeFragmentRendererTest.php index 546d48bc0b..3ccdab8385 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Fragment/ContainerAwareHIncludeFragmentRendererTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Fragment/LegacyContainerAwareHIncludeFragmentRendererTest.php @@ -15,10 +15,12 @@ use Symfony\Bundle\FrameworkBundle\Tests\TestCase; use Symfony\Bundle\FrameworkBundle\Fragment\ContainerAwareHIncludeFragmentRenderer; use Symfony\Component\HttpFoundation\Request; -class ContainerAwareHIncludeFragmentRendererTest extends TestCase +class LegacyContainerAwareHIncludeFragmentRendererTest extends TestCase { public function testRender() { + $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); + $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); $container->expects($this->once()) ->method('get') 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 cefa7de7c1..783014ee9e 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 @@ -19,23 +19,7 @@ class FragmentController extends ContainerAware { public function indexAction(Request $request) { - $actions = $this->container->get('templating')->get('actions'); - - $html1 = $actions->render($actions->controller('TestBundle:Fragment:inlined', array( - 'options' => array( - 'bar' => new Bar(), - 'eleven' => 11, - ), - ))); - - $html2 = $actions->render($actions->controller('TestBundle:Fragment:customformat', array('_format' => 'html'))); - - $html3 = $actions->render($actions->controller('TestBundle:Fragment:customlocale', array('_locale' => 'es'))); - - $request->setLocale('fr'); - $html4 = $actions->render($actions->controller('TestBundle:Fragment:forwardlocale')); - - return new Response($html1.'--'.$html2.'--'.$html3.'--'.$html4); + return $this->container->get('templating')->renderResponse('fragment.html.php', array('bar' => new Bar())); } public function inlinedAction($options, $_format) diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Resources/fragment.html.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Resources/fragment.html.php new file mode 100644 index 0000000000..8ea3c36f8a --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/app/Resources/fragment.html.php @@ -0,0 +1,14 @@ +get('actions')->render($this->get('actions')->controller('TestBundle:Fragment:inlined', array( + 'options' => array( + 'bar' => $bar, + 'eleven' => 11, + ), + ))); +?>--get('actions')->render($this->get('actions')->controller('TestBundle:Fragment:customformat', array('_format' => 'html'))); +?>--get('actions')->render($this->get('actions')->controller('TestBundle:Fragment:customlocale', array('_locale' => 'es'))); +?>--getRequest()->setLocale('fr'); + echo $this->get('actions')->render($this->get('actions')->controller('TestBundle:Fragment:forwardlocale')); +?>