[FrameworkBundle] added the possibility to render a template for a different format than the one from the current Request
This commit is contained in:
parent
51680a2d95
commit
f48aeb1021
@ -136,7 +136,7 @@ class Engine extends BaseEngine
|
||||
return $parameters;
|
||||
}
|
||||
|
||||
// Bundle:controller:action(:renderer)
|
||||
// Bundle:controller:action(.format)(:renderer)
|
||||
public function splitTemplateName($name, array $defaults = array())
|
||||
{
|
||||
$parts = explode(':', $name, 4);
|
||||
@ -157,14 +157,19 @@ class Engine extends BaseEngine
|
||||
)
|
||||
);
|
||||
|
||||
if (isset($parts[3]) && $parts[3]) {
|
||||
$options['renderer'] = $parts[3];
|
||||
}
|
||||
|
||||
if (false !== $pos = strpos($parts[2], '.')) {
|
||||
$options['format'] = substr($parts[2], $pos);
|
||||
$parts[2] = substr($parts[2], 0, $pos);
|
||||
} else {
|
||||
$format = $this->container->getRequestService()->getRequestFormat();
|
||||
if (null !== $format && 'html' !== $format) {
|
||||
$options['format'] = '.'.$format;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($parts[3]) && $parts[3]) {
|
||||
$options['renderer'] = $parts[3];
|
||||
}
|
||||
|
||||
return array($parts[2], $options);
|
||||
}
|
||||
|
Reference in New Issue
Block a user