如何在symfony中将helper加载到另一个帮助器中

I want to use the distance_of_time_in_words function from DateHelper into another Helper.

How to use symfony DateHelper into my custom Helper?

Any hint is very much appreciated.

I think I found the solution.

Added following line before calling distance_of_time_in_words() function in my helper.

sfProjectConfiguration::getActive()->loadHelpers(array('Date'));

That is what I needed, Thanks.

I think the best way, is to define your helper globally, in your apps/frontend/config/settings.yml:

all:
  .settings:
    standard_helpers:  [Partial, Cache, I18N, Date]

This way, all the helpers from standard_helpers will always be loaded and available in your view.

Ps: be careful to not override your own standard_helpers but just add Date to the end.