I'm rendering a partial from inside a task in symfony 1.4.6...
$this->configuration = $this->createConfiguration(app, env, false);
$this->configuration->loadHelpers(array('Partial'));
$context = sfContext::createInstance($this->configuration);
$html = get_partial(partialName, params);
...Inside the partial there is a reference to a custom helper, which can't be referenced from the default context, so an exception is throw...
Unable to load "fooHelper.php" helper in: SF_ROOT_DIR/apps/frontend/lib/helper, SF_ROOT_DIR/lib/helper, SF_ROOT_DIR/lib/vendor/symfony/lib/helper.
...And attempting to load the custom helper from the task referencing the module name in loadHelpers
doesn't seem to fix the issue either...
$this->configuration->loadHelpers(array('Partial'), moduleName);
The helper I am trying to load is specific to the module, I don't really want to 开发者_StackOverflowmove it to one of the default project helper directories listed in the exception above. Any help would be appreciated!
Please have a look at the content of the HelperHelper.php helper file. use_helper() can be used in a partial, so I guess putting this piece of code on top of the partial would do the job:
$context = sfContext::getInstance();
$context->getConfiguration()->loadHelpers(array('Custom'), 'moduleName');
精彩评论