Skip to content

[HttpKernel] renamed sub-request classes #6871

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/Symfony/Bridge/Twig/Extension/HttpKernelExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Symfony\Bridge\Twig\Extension;

use Symfony\Component\HttpKernel\HttpContentRenderer;
use Symfony\Component\HttpKernel\SubRequestRenderer;
use Symfony\Component\HttpKernel\Controller\ControllerReference;

/**
Expand All @@ -26,9 +26,9 @@ class HttpKernelExtension extends \Twig_Extension
/**
* Constructor.
*
* @param HttpContentRenderer $renderer A HttpContentRenderer instance
* @param SubRequestRenderer $renderer A SubRequestRenderer instance
*/
public function __construct(HttpContentRenderer $renderer)
public function __construct(SubRequestRenderer $renderer)
{
$this->renderer = $renderer;
}
Expand All @@ -50,7 +50,7 @@ public function getFunctions()
*
* @return string The Response content
*
* @see Symfony\Component\HttpKernel\HttpContentRenderer::render()
* @see Symfony\Component\HttpKernel\SubRequestRenderer::render()
*/
public function render($uri, $options = array())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use Symfony\Bridge\Twig\Tests\TestCase;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\HttpContentRenderer;
use Symfony\Component\HttpKernel\SubRequestRenderer;

class HttpKernelExtensionTest extends TestCase
{
Expand All @@ -35,7 +35,7 @@ protected function setUp()
*/
public function testRenderWithError()
{
$kernel = $this->getHttpContentRenderer($this->throwException(new \Exception('foo')));
$kernel = $this->getSubRequestRenderer($this->throwException(new \Exception('foo')));

$loader = new \Twig_Loader_Array(array('index' => '{{ render("foo") }}'));
$twig = new \Twig_Environment($loader, array('debug' => true, 'cache' => false));
Expand All @@ -44,7 +44,7 @@ public function testRenderWithError()
$this->renderTemplate($kernel);
}

protected function getHttpContentRenderer($return)
protected function getSubRequestRenderer($return)
{
$strategy = $this->getMock('Symfony\\Component\\HttpKernel\\RenderingStrategy\\RenderingStrategyInterface');
$strategy->expects($this->once())->method('getName')->will($this->returnValue('default'));
Expand All @@ -58,13 +58,13 @@ protected function getHttpContentRenderer($return)
->will($this->returnValue(Request::create('/')))
;

$renderer = new HttpContentRenderer(array($strategy));
$renderer = new SubRequestRenderer(array($strategy));
$renderer->onKernelRequest($event);

return $renderer;
}

protected function renderTemplate(HttpContentRenderer $renderer, $template = '{{ render("foo") }}')
protected function renderTemplate(SubRequestRenderer $renderer, $template = '{{ render("foo") }}')
{
$loader = new \Twig_Loader_Array(array('index' => $template));
$twig = new \Twig_Environment($loader, array('debug' => true, 'cache' => false));
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ CHANGELOG
* [BC BREAK] restricted the `Symfony\Bundle\FrameworkBundle\HttpKernel::render()` method to only accept URIs or ControllerReference instances
* `Symfony\Bundle\FrameworkBundle\HttpKernel::render()` method signature changed and the first argument
must now be a URI or a ControllerReference instance (the `generateInternalUri()` method was removed)
* The internal routes (`Resources/config/routing/internal.xml`) have been removed and replaced with a listener (`Symfony\Component\HttpKernel\EventListener\RouterProxyListener`)
* The internal routes (`Resources/config/routing/internal.xml`) have been removed and replaced with a listener (`Symfony\Component\HttpKernel\EventListener\SubRequestListener`)
* The `render` method of the `actions` templating helper signature and arguments changed
* replaced Symfony\Bundle\FrameworkBundle\Controller\TraceableControllerResolver by Symfony\Component\HttpKernel\Controller\TraceableControllerResolver
* replaced Symfony\Component\HttpKernel\Debug\ContainerAwareTraceableEventDispatcher by Symfony\Component\HttpKernel\Debug\TraceableEventDispatcher
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ class HttpRenderingStrategyPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container)
{
if (false === $container->hasDefinition('http_content_renderer')) {
if (false === $container->hasDefinition('sub_request_renderer')) {
return;
}

$definition = $container->getDefinition('http_content_renderer');
$definition = $container->getDefinition('sub_request_renderer');
foreach (array_keys($container->findTaggedServiceIds('kernel.content_renderer_strategy')) as $id) {
// We must assume that the class value has been correctly filled, even if the service is created by a factory
$class = $container->getDefinition($id)->getClass();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function load(array $configs, ContainerBuilder $container)

$loader->load('web.xml');
$loader->load('services.xml');
$loader->load('content_generator.xml');
$loader->load('sub_request.xml');

// A translator must always be registered (as support is included by
// default in the Form component). If disabled, an identity translator
Expand Down
6 changes: 3 additions & 3 deletions src/Symfony/Bundle/FrameworkBundle/HttpKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,17 @@ public function forward($controller, array $attributes = array(), array $query =
* @throws \RuntimeException
* @throws \Exception
*
* @deprecated in 2.2, will be removed in 2.3 (use Symfony\Component\HttpKernel\HttpContentRenderer::render() instead)
* @deprecated in 2.2, will be removed in 2.3 (use Symfony\Component\HttpKernel\SubRequestRenderer::render() instead)
*/
public function render($uri, array $options = array())
{
trigger_error('render() is deprecated since version 2.2 and will be removed in 2.3. Use Symfony\Component\HttpKernel\HttpContentRenderer::render() instead.', E_USER_DEPRECATED);
trigger_error('render() is deprecated since version 2.2 and will be removed in 2.3. Use Symfony\Component\HttpKernel\SubRequestRenderer::render() instead.', E_USER_DEPRECATED);

$options = $this->renderer->fixOptions($options);

$strategy = isset($options['strategy']) ? $options['strategy'] : 'default';
unset($options['strategy']);

$this->container->get('http_content_renderer')->render($uri, $strategy, $options);
$this->container->get('sub_request_renderer')->render($uri, $strategy, $options);
}
}

This file was deleted.

8 changes: 4 additions & 4 deletions src/Symfony/Bundle/FrameworkBundle/Resources/config/esi.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parameters>
<parameter key="esi.class">Symfony\Component\HttpKernel\HttpCache\Esi</parameter>
<parameter key="esi_listener.class">Symfony\Component\HttpKernel\EventListener\EsiListener</parameter>
<parameter key="http_content_renderer.strategy.esi.class">Symfony\Component\HttpKernel\RenderingStrategy\EsiRenderingStrategy</parameter>
<parameter key="sub_request_renderer.strategy.esi.class">Symfony\Component\HttpKernel\RenderingStrategy\EsiRenderingStrategy</parameter>
</parameters>

<services>
Expand All @@ -18,11 +18,11 @@
<argument type="service" id="esi" on-invalid="ignore" />
</service>

<service id="http_content_renderer.strategy.esi" class="%http_content_renderer.strategy.esi.class%">
<service id="sub_request_renderer.strategy.esi" class="%sub_request_renderer.strategy.esi.class%">
<tag name="kernel.content_renderer_strategy" />
<argument type="service" id="esi" />
<argument type="service" id="http_content_renderer.strategy.default" />
<call method="setProxyPath"><argument>%http_content_renderer.proxy_path%</argument></call>
<argument type="service" id="sub_request_renderer.strategy.default" />
<call method="setProxyPath"><argument>%sub_request_renderer.proxy_path%</argument></call>
</service>
</services>
</container>
6 changes: 3 additions & 3 deletions src/Symfony/Bundle/FrameworkBundle/Resources/config/proxy.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">

<parameters>
<parameter key="http_content_renderer.listener.router_proxy.class">Symfony\Component\HttpKernel\EventListener\RouterProxyListener</parameter>
<parameter key="sub_request_renderer.listener.class">Symfony\Component\HttpKernel\EventListener\SubRequestListener</parameter>
</parameters>

<services>
<service id="http_content_renderer.listener.router_proxy" class="%http_content_renderer.listener.router_proxy.class%">
<service id="sub_request_renderer.listener" class="%sub_request_renderer.listener.class%">
<tag name="kernel.event_subscriber" />
<argument type="service" id="uri_signer" />
<argument>%http_content_renderer.proxy_path%</argument>
<argument>%sub_request_renderer.proxy_path%</argument>
</service>
</services>
</container>
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0" ?>

<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">

<parameters>
<parameter key="sub_request_renderer.class">Symfony\Component\HttpKernel\SubRequestRenderer</parameter>
<parameter key="sub_request_renderer.strategy.inline.class">Symfony\Component\HttpKernel\RenderingStrategy\InlineRenderingStrategy</parameter>
<parameter key="sub_request_renderer.strategy.hinclude.class">Symfony\Bundle\FrameworkBundle\RenderingStrategy\ContainerAwareHIncludeRenderingStrategy</parameter>
<parameter key="sub_request_renderer.strategy.hinclude.global_template"></parameter>
<parameter key="sub_request_renderer.proxy_path">/_proxy</parameter>
</parameters>

<services>
<service id="sub_request_renderer" class="%sub_request_renderer.class%">
<tag name="kernel.event_subscriber" />
<argument type="collection" />
<argument>%kernel.debug%</argument>
</service>

<service id="sub_request_renderer.strategy.inline" class="%sub_request_renderer.strategy.inline.class%">
<tag name="kernel.content_renderer_strategy" />
<argument type="service" id="http_kernel" />
<call method="setProxyPath"><argument>%sub_request_renderer.proxy_path%</argument></call>
</service>

<service id="sub_request_renderer.strategy.hinclude" class="%sub_request_renderer.strategy.hinclude.class%">
<tag name="kernel.content_renderer_strategy" />
<argument type="service" id="service_container" />
<argument type="service" id="uri_signer" />
<argument>%sub_request_renderer.strategy.hinclude.global_template%</argument>
<call method="setProxyPath"><argument>%sub_request_renderer.proxy_path%</argument></call>
</service>

</services>
</container>
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@

<service id="templating.helper.actions" class="%templating.helper.actions.class%">
<tag name="templating.helper" alias="actions" />
<argument type="service" id="http_content_renderer" />
<argument type="service" id="sub_request_renderer" />
</service>

<service id="templating.helper.code" class="%templating.helper.code.class%">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
namespace Symfony\Bundle\FrameworkBundle\Templating\Helper;

use Symfony\Component\Templating\Helper\Helper;
use Symfony\Component\HttpKernel\HttpContentRenderer;
use Symfony\Component\HttpKernel\SubRequestRenderer;
use Symfony\Component\HttpKernel\Controller\ControllerReference;

/**
Expand All @@ -27,9 +27,9 @@ class ActionsHelper extends Helper
/**
* Constructor.
*
* @param HttpContentRenderer $renderer A HttpContentRenderer instance
* @param SubRequestRenderer $renderer A SubRequestRenderer instance
*/
public function __construct(HttpContentRenderer $renderer)
public function __construct(SubRequestRenderer $renderer)
{
$this->renderer = $renderer;
}
Expand All @@ -42,7 +42,7 @@ public function __construct(HttpContentRenderer $renderer)
*
* @return string
*
* @see Symfony\Component\HttpKernel\HttpContentRenderer::render()
* @see Symfony\Component\HttpKernel\SubRequestRenderer::render()
*/
public function render($uri, array $options = array())
{
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@

<service id="twig.extension.httpkernel" class="%twig.extension.httpkernel.class%" public="false">
<tag name="twig.extension" />
<argument type="service" id="http_content_renderer" />
<argument type="service" id="sub_request_renderer" />
</service>

<service id="twig.extension.form" class="%twig.extension.form.class%" public="false">
Expand Down
7 changes: 3 additions & 4 deletions src/Symfony/Component/HttpKernel/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ CHANGELOG
2.2.0
-----

* added Symfony\Component\HttpKernel\EventListener\RouterProxyListener
* added Symfony\Component\HttpKernel\UriSigner
* added Symfony\Component\HttpKernel\HttpContentRenderer and rendering strategies (in Symfony\Component\HttpKernel\RenderingStrategy)
* added Symfony\Component\HttpKernel\EventListener\RouterProxyListener
* added Symfony\Component\HttpKernel\SubRequestRenderer and rendering strategies (in Symfony\Component\HttpKernel\RenderingStrategy)
* added Symfony\Component\HttpKernel\EventListener\SubRequestListener
* added Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel
* added ControllerReference to create reference of Controllers (used in the HttpContentRenderer class)
* added ControllerReference to create reference of Controllers (used in the SubRequestRenderer class)
* [BC BREAK] renamed TimeDataCollector::getTotalTime() to
TimeDataCollector::getDuration()
* updated the MemoryDataCollector to include the memory used in the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*
* @author Fabien Potencier <fabien@symfony.com>
*
* @see Symfony\Component\HttpKernel\HttpContentRenderer
* @see Symfony\Component\HttpKernel\SubRequestRenderer
* @see Symfony\Component\HttpKernel\RenderingStrategy\RenderingStrategyInterface
*/
class ControllerReference
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class RouterProxyListener implements EventSubscriberInterface
class SubRequestListener implements EventSubscriberInterface
{
private $signer;
private $proxyPath;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class EsiRenderingStrategy extends ProxyAwareRenderingStrategy
* Constructor.
*
* The "fallback" strategy when ESI is not available should always be an
* instance of DefaultRenderingStrategy (or a class you are using for the
* instance of InlineRenderingStrategy (or a class you are using for the
* default strategy).
*
* @param Esi $esi An Esi instance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class DefaultRenderingStrategy extends ProxyAwareRenderingStrategy
class InlineRenderingStrategy extends ProxyAwareRenderingStrategy
{
private $kernel;

Expand Down Expand Up @@ -95,6 +95,6 @@ protected function createSubRequest($uri, Request $request)
*/
public function getName()
{
return 'default';
return 'inline';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

use Symfony\Component\HttpKernel\Controller\ControllerReference;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\EventListener\RouterProxyListener;
use Symfony\Component\HttpKernel\EventListener\SubRequestListener;

/**
* Adds the possibility to generate a proxy URI for a given Controller.
Expand All @@ -29,7 +29,7 @@ abstract class ProxyAwareRenderingStrategy implements RenderingStrategyInterface
*
* @param string $path The path
*
* @see RouterProxyListener
* @see SubRequestListener
*/
public function setProxyPath($path)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*
* @author Fabien Potencier <fabien@symfony.com>
*
* @see Symfony\Component\HttpKernel\HttpContentRenderer
* @see Symfony\Component\HttpKernel\SubRequestRenderer
*/
interface RenderingStrategyInterface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
*
* @see RenderingStrategyInterface
*/
class HttpContentRenderer implements EventSubscriberInterface
class SubRequestRenderer implements EventSubscriberInterface
{
private $debug;
private $strategies;
Expand Down
Loading