[FrameworkBundle] added the possibility to render a template for a different format than the one from the current Request

This commit is contained in:
Fabien Potencier 2010-08-17 19:16:36 +02:00
parent 51680a2d95
commit f48aeb1021

View File

@ -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,13 +157,18 @@ 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;
}
}
$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);