Permalink
Browse files

make it possible to override the template inside a twig call

  • Loading branch information...
1 parent 9086001 commit 3e85a637afdbeeb39d94e0b89ec928fb8a025b14 @lsmith77 lsmith77 committed Dec 21, 2012
Showing with 7 additions and 11 deletions.
  1. +5 −9 Templating/Helper/LocaleSwitchHelper.php
  2. +2 −2 Twig/Extension/LocaleSwitcherExtension.php
View
14 Templating/Helper/LocaleSwitchHelper.php
@@ -35,22 +35,18 @@ class LocaleSwitchHelper extends Helper
public function __construct(EngineInterface $templating, $template)
{
$this->templating = $templating;
- if (array_key_exists($template, $this->templates)) {
- $this->view = $this->templates[$template];
-
- return;
- }
- $this->view = $template;
-
+ $this->view = array_key_exists($template, $this->templates)
+ ? $this->templates[$template] : $template;
}
/**
*
* @param array $viewParams
*/
- public function renderSwitch(array $viewParams = array())
+ public function renderSwitch(array $viewParams = array(), $template = null)
{
- return $this->templating->render($this->view, $viewParams);
+ $template = $template ?: $this->view;
+ return $this->templating->render($template, $viewParams);
}
/**
View
4 Twig/Extension/LocaleSwitcherExtension.php
@@ -57,7 +57,7 @@ public function getName()
* @param string $route A route name for which the switch has to be made
* @param array $parameters
*/
- public function renderSwitcher($route = null, $parameters = array())
+ public function renderSwitcher($route = null, $parameters = array(), $template = null)
{
$showCurrentLocale = $this->container->getParameter('lunetics_locale.switcher.show_current_locale');
$useController = $this->container->getParameter('lunetics_locale.switcher.use_controller');
@@ -69,6 +69,6 @@ public function renderSwitcher($route = null, $parameters = array())
$infos = $infosBuilder->getTargetInformations($route, $parameters);
- return $this->container->get('lunetics_locale.switcher_helper')->renderSwitch($infos, 'switcher_links.html.twig');
+ return $this->container->get('lunetics_locale.switcher_helper')->renderSwitch($infos, $template);
}
}

0 comments on commit 3e85a63

Please sign in to comment.