[FrameworkBundle] Added support for default templates per render tag

This commit is contained in:
Pierre du Plessis 2012-11-12 16:24:16 +02:00
parent f4c05e3fe8
commit 74a8fcf013
2 changed files with 13 additions and 3 deletions

View File

@ -10,6 +10,7 @@ CHANGELOG
* A new parameter has been added to the DIC: `router.request_context.base_url`
You can customize it for your functional tests or for generating urls with
the right base url when your are in the cli context.
* Added support for default templates per render tag
2.1.0
-----

View File

@ -105,6 +105,7 @@ class HttpKernel extends BaseHttpKernel
'alt' => array(),
'standalone' => false,
'comment' => '',
'default' => null,
), $options);
if (!is_array($options['alt'])) {
@ -130,8 +131,16 @@ class HttpKernel extends BaseHttpKernel
$uri = $this->generateInternalUri($controller, $options['attributes'], $options['query'], false);
$defaultContent = null;
if ($template = $this->container->getParameter('templating.hinclude.default_template')) {
$defaultContent = $this->container->get('templating')->render($template);
$templating = $this->container->get('templating');
if ($options['default']) {
if ($templating->exists($options['default'])) {
$defaultContent = $templating->render($options['default']);
} else {
$defaultContent = $options['default'];
}
} elseif ($template = $this->container->getParameter('templating.hinclude.default_template')) {
$defaultContent = $templating->render($template);
}
return $this->renderHIncludeTag($uri, $defaultContent);
@ -226,7 +235,7 @@ class HttpKernel extends BaseHttpKernel
/**
* Renders an HInclude tag.
*
* @param string $uri A URI
* @param string $uri A URI
* @param string $defaultContent Default content
*/
public function renderHIncludeTag($uri, $defaultContent = null)