Development

#1914 (Teach Helpers to load other Helpers that they depend on.)

You must first sign up to be able to contribute.

Ticket #1914 (new enhancement)

Opened 1 year ago

Last modified 1 year ago

Teach Helpers to load other Helpers that they depend on.

Reported by: Andrejs.Verza Assigned to: fabien
Priority: major Milestone:
Component: helpers Version: 1.0.5
Keywords: helper Cc:
Qualification:

Description

Whenever I sfLoader::loadHelpers() in action, I have to guess what helpers to load BEFORE that one I need, because helpers depend on each other. Therefore I suggest patching ALL helpers to load themselves whatever they need.

Change History

07/07/07 02:49:10 changed by Andrejs.Verza

I suggest loading default helpers on first demand of ANY helper in ANY place. (This probably requires patching sfLoader class. Not bad idea to remember if we have already loaded the default helpers.)

For example, I tried to use update_element_function of Javascript helper in action code. Simple AJAX action, therefore there is no need for template for that action.

In the result I get an error telling that there is no escape_javascript function defined, which of course is defined, but in the Tag helper. Well, I can get to know it only having set 'complete' => 'alert (request.responseText)'. So, I loadHelper (array ('Tag', 'Javascript')).

07/10/07 00:30:10 changed by Andrejs.Verza

  • priority changed from minor to major.

As this problem with Helper dependencies becomes more and more irritating for me while writting an intense AJAX module that sometimes include partials or use some of Object helpers, I finally found quite simple solution.

So, my brilliant suggestion is to move (refactor) loadCoreAndStandardHelpers() method from the PHPView class into sfLoader class and make it static. If so, one could call this method from the action code, if one needs helpers and doesn't want to explore dependencies.

This modification is simple, because the loadCoreAndStandardHelpers() method is used only once it the same class of PHPView, where it is defined. There we could replace it with sfLoader::loadStandardHelpers() or something. And the sfLoader class gets loaded anyway.