Skip to content

Commit

Permalink
make it possible to override the template inside a twig call
Browse files Browse the repository at this point in the history
  • Loading branch information
lsmith77 committed Dec 21, 2012
1 parent 9086001 commit 3e85a63
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
14 changes: 5 additions & 9 deletions Templating/Helper/LocaleSwitchHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions Twig/Extension/LocaleSwitcherExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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.