Created
November 21, 2012 21:51
-
-
Save gbasov/4128094 to your computer and use it in GitHub Desktop.
localized_current_url
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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