Is it possible to capture the output of an action in a task?
Ex:
FooAction
{
executeIndexSuccess()
}
and in my Task:
FooAction->Index
Is this possible?
Yes. In your task's execute()
method:
sfContext::createInstance($this->configuration);
$output = sfContext::getInstance()->getController()->getPresentationFor("module", "action");
The resultant output from the action and associated view will be stored in $output
.
If your action needs variables setting into the session, you can also do things like:
sfContext::getInstance()->getUser()->setAttribute("mySessionVar", 123);
sfContext::getInstance()->getUser()->setFlash("myFlashVar", "foo");
before you call getPresentationFor()
, so that the variables are present when the action is executed.