moved the deprecation logic calls outside the new HttpContentRenderer class

This commit is contained in:
Fabien Potencier 2013-01-06 11:00:55 +01:00
parent bd102c5eba
commit 2eea7682e7
4 changed files with 8 additions and 6 deletions

View File

@ -54,6 +54,8 @@ class HttpKernelExtension extends \Twig_Extension
*/
public function render($uri, $options = array())
{
$options = $this->renderer->fixOptions($options);
$strategy = isset($options['strategy']) ? $options['strategy'] : 'default';
unset($options['strategy']);

View File

@ -105,6 +105,8 @@ class HttpKernel extends BaseHttpKernel
{
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);
$options = $this->renderer->fixOptions($options);
$strategy = isset($options['strategy']) ? $options['strategy'] : 'default';
unset($options['strategy']);

View File

@ -46,6 +46,8 @@ class ActionsHelper extends Helper
*/
public function render($uri, array $options = array())
{
$options = $this->renderer->fixOptions($options);
$strategy = isset($options['strategy']) ? $options['strategy'] : 'default';
unset($options['strategy']);

View File

@ -97,11 +97,6 @@ class HttpContentRenderer implements EventSubscriberInterface
$options['ignore_errors'] = !$this->debug;
}
$options = $this->fixOptions($options);
if (isset($options['strategy'])) {
$strategy = $options['strategy'];
}
if (!isset($this->strategies[$strategy])) {
throw new \InvalidArgumentException(sprintf('The "%s" rendering strategy does not exist.', $strategy));
}
@ -118,7 +113,7 @@ class HttpContentRenderer implements EventSubscriberInterface
}
// to be removed in 2.3
private function fixOptions($options)
public function fixOptions(array $options)
{
// support for the standalone option is @deprecated in 2.2 and replaced with the strategy option
if (isset($options['standalone'])) {
@ -136,6 +131,7 @@ class HttpContentRenderer implements EventSubscriberInterface
}
$options['strategy'] = $options['standalone'];
unset($options['standalone']);
}
return $options;