Loading helpers from an action or model in Symfony 1.2

Just quick post today about loading helpers in symfony 1.2 from an action or model.

Previously I would use the sfLoader class to load a helper, but it now says:

The sfLoader::loadHelpers() method is deprecated. Please use the same method from sfApplicationConfiguration.

So, from the action you should now use:

$this->getContext()->getConfiguration()->loadHelpers('Url');

From the model you can use:

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

Tags: ,

3 Responses to “Loading helpers from an action or model in Symfony 1.2”

  1. Éric Rogé 19/03/2009 at 7:41 am #

    Be carefull,

    sfContext is not instancied in tasks, so it might not be avaible in your Model.

  2. Noel 19/03/2009 at 8:51 am #

    Hello,

    You should use sfProjectConfiguration::getActive()->loadHelpers(array(‘Url’)); instead of sfContext, which won’t be instancied in some cases (tests, tasks).

    Noel

  3. jamie 20/03/2009 at 6:14 am #

    thanks guys, never thought of that.

Leave a Reply