Hi *,
I have bunch of routing rules in .yml file, they're all custom urls, I
also have array of parameters
and now I want to find the route that matches passed parameters
that is strange that I tried all helper functions like url_for/link_to
etc. but none of them generate me correct url.
so I wrote this function which does what I need
<code>
function custom_url_for($parameters)
{
$routing = sfContext::getInstance()->getRouting();
foreach($routing->getRoutes() as $routeName => $routeObject)
{
$match = $routeObject->matchesParameters($parameters);
if ( $match && $routeName != 'default' )
{
$parameters['sf_route'] = $routeName;
}
}
return url_for($parameters);
}
</code>
the $parameters array usually looks like this:
array(
'module' => $sf_params->get('module'),
'action' => $sf_params->get('action'),
'param1' => $sf_params->get('param1'),
'param2' => $sf_params->get('param2'),
'param3' => $sf_params->get('param3'),
// etc
)
The code above finds the last matched route and produces pretty url
based on that route.
is there standart way to do this?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---