Skip to content

Instantly share code, notes, and snippets.

@gbasov
Created November 21, 2012 21:51
Show Gist options
  • Save gbasov/4128094 to your computer and use it in GitHub Desktop.
Save gbasov/4128094 to your computer and use it in GitHub Desktop.
localized_current_url
function localized_current_url($sf_culture = null)
{
if (! $sf_culture)
{
throw new sfException(sprintf('Invalid parameter $sf_culture "%s".', $sf_culture));
}
$routing = sfContext::getInstance()->getRouting();
$request = sfContext::getInstance()->getRequest();
$controller = sfContext::getInstance()->getController();
// depending on your routing configuration, you can set $route_name = $routing->getCurrentRouteName()
$route_name = '';
$parameters = $controller->convertUrlStringToParameters($routing->getCurrentInternalUri());
$parameters[1]['sf_culture'] = $sf_culture;
return $routing->generate($route_name, array_merge($request->getGetParameters(), $parameters[1]));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment