[FrameworkBundle] Added support for default templates per render tag
This commit is contained in:
parent
f4c05e3fe8
commit
74a8fcf013
@ -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
|
||||
-----
|
||||
|
@ -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)
|
||||
|
Reference in New Issue
Block a user