Code snippets for symfony 1.x


Refine Tags

Snippets tagged "action url"

Get the module, action and parameters from a url

The problem

You want to get the module, action and parameters associated to a given url, pretty much as the routing system does.

The solution

First you will have to remove the part of the url which is not symfony specific. That part typically looks like Once you've done that execute the following code:

$r = new sfRouting();
$params = $r->parse($myUrl);
$module = $params['module'];
$action = $params['action'];

Now the module and action associated to this url are as above in $module and $action and the parameters are the remaining elements of the array $params.

by Olivier Verdier on 2006-07-21, tagged action  module  parameters  routing  url