views:

1387

answers:

1

I am building a URL inside of a class and I'd like to be able to change the routing if necessary later by just changing the routing.yml file.

If I have the route:

userSignup:
  url:   /user/signup
  param: { module: user, action: signup }

How can I use the url_for('userSignup') helper in a class to dynamically create the URL?

+3  A: 

I only tried this with 1.2 so I can't speak for any previous versions...

From any of your classes:

sfContext::getInstance()->getConfiguration->loadHelpers(array('Url'));

...then you can continue with using any of the functions defined in the url helper.

Kyril
Yes, this works like a charm in 1.2. But I do get -- The sfLoader::loadHelpers() method is deprecated. Please use the same method from sfApplicationConfiguration.
Failpunk