Reputation: 4138
I am new to symfony.
How can I get from Symfony 1.4 the URI path ?
I have tryied like that:
sfContext::getInstance()->getRequest()->getRelativeUrlRoot()
but is not working.
Upvotes: 12
Views: 26469
Reputation: 30698
Like this:
sfContext::getInstance()->getRouting()->getCurrentInternalUri();
This one might be of use too:
sfContext::getInstance()->getRouting()->getCurrentRouteName();
UPDATE:
Please see Damien's answer below and im3r3k's comment for what seems to be a better method as it does not rely on context.
Upvotes: 12
Reputation: 5882
getCurrentInternalUri is, like his name tell, the internal URL, to be used in internal routing functions such as link_to.
The question is about the current URI and even if the previous answer is marked as accepted, here is the method to fetch the current URI in symfony 1.4.
$context->getRequest()->getUri();
In an action :
public function executeDelete(sfWebRequest $request)
{
$uri = $request->getUri();
}
Upvotes: 23