8000 [HttpKernel] made the strategy a regular parameter in HttpContentRend… · symfony/symfony@1240690 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1240690

Browse files
committed
[HttpKernel] made the strategy a regular parameter in HttpContentRenderer::render()
1 parent adc067e commit 1240690

File tree

4 files changed

+22
-12
lines changed

4 files changed

+22
-12
lines changed

src/Symfony/Bridge/Twig/Extension/HttpKernelExtension.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,15 @@ public function getFunctions()
5454
*/
5555
public function render($uri, $options = array())
5656
{
57-
return $this->renderer->render($uri, $options);
57+
$strategy = isset($options['strategy']) ? $options['strategy'] : 'default';
58+
unset($options['strategy']);
59+
60+
return $this->renderer->render($uri, $strategy, $options);
5861
}
5962

6063
public function renderStrategy($strategy, $uri, $options = array())
6164
{
62-
$options['strategy'] = $strategy;
63-
64-
return $this->renderer->render($uri, $options);
65+
return $this->renderer->render($uri, $strategy, $options);
6566
}
6667

6768
public function controller($controller, $attributes = array(), $query = array())

src/Symfony/Bundle/FrameworkBundle/HttpKernel.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ public function render($uri, array $options = array())
101101
{
102102
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);
103103

104-
$this->container->get('http_content_renderer')->render($uri, $options);
104+
$strategy = isset($options['strategy']) ? $options['strategy'] : 'default';
105+
unset($options['strategy']);
106+
107+
$this->container->get('http_content_renderer')->render($uri, $strategy, $options);
105108
}
106109
}

src/Symfony/Bundle/FrameworkBundle/Templating/Helper/ActionsHelper.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ public function __construct(HttpContentRenderer $renderer)
4646
*/
4747
public function render($uri, array $options = array())
4848
{
49-
return $this->renderer->render($uri, $options);
49+
$strategy = isset($options['strategy']) ? $options['strategy'] : 'default';
50+
unset($options['strategy']);
51+
52+
return $this->renderer->render($uri, $strategy, $options);
5053
}
5154

5255
public function controller($controller, $attributes = array(), $query = array())

src/Symfony/Component/HttpKernel/HttpContentRenderer.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,23 +81,26 @@ public function onKernelResponse(FilterResponseEvent $event)
8181
* When the Response is a StreamedResponse, the content is streamed immediately
8282
* instead of being returned.
8383
*
84+
* Available options:
85+
*
8486
* * ignore_errors: true to return an empty string in case of an error
85-
* * strategy: the strategy to use for rendering
8687
*
87-
* @param string|ControllerReference $uri A URI as a string or a ControllerReference instance
88-
* @param array $options An array of options
88+
* @param string|ControllerReference $uri A URI as a string or a ControllerReference instance
89+
* @param string $strategy The strategy to use for the rendering
90+
* @param array $options An array of options
8991
*
9092
* @return string|null The Response content or null when the Response is streamed
9193
*/
92-
public function render($uri, array $options = array())
94+
public function render($uri, $strategy = 'default', array $options = array())
9395
{
9496
if (!isset($options['ignore_errors'])) {
9597
$options['ignore_errors'] = !$this->debug;
9698
}
9799

98100
$options = $this->fixOptions($options);
99-
100-
$strategy = isset($options['strategy']) ? $options['strategy'] : 'default';
101+
if (isset($options['strategy'])) {
102+
$strategy = $options['strategy'];
103+
}
101104

102105
if (!isset($this->strategies[$strategy])) {
103106
throw new \InvalidArgumentException(sprintf('The "%s" rendering strategy does not exist.', $strategy));

0 commit comments

Comments
 (0)
0