hi
i have implemented a function to execute a task from action
I have created a new instance of the sfFormatter class.
// here class_name is the class name of the task to be executed
public static function executeTask($class_name, $arguments = array(),
$options = array())
{
$dispatcher = sfContext::getInstance()->getEventDispatcher();
$formatter = new sfFormatter();
$task = new $class_name($dispatcher, $formatter);
chdir(sfConfig::get('sf_root_dir'));
$task->run($arguments, $options);
}
e.g to execute the clearCache task
public static function clearCache()
{
$class_name = "sfCacheClearTask";
self::executeTask($class_name);
}
On Tue, Jul 21, 2009 at 10:22 PM, Gandalf <[email protected]> wrote:
>
> Hello,
>
> I need to run a task from an action, NOT using exec, cant find how,
> this is what im trying:
>
> I cant find a instance of sfFormatter to pass
>
> Any clue? I dont want to rely on exec to do this.
>
> Thanks!!!!
>
> Pablo
> ------------
>
> public function executeIndex(sfWebRequest $request)
> {
> $this -> form = new ExportForm;
> if ($request -> isMethod ('post')){
> $this -> form -> bind ($request -> getParameter ('export'));
> if ($this -> form -> isValid ()){
> $email = $this -> form -> getValue ('email');
>
> $task = new acopDumpEmailDataTask ($this->dispatcher,
> $this->formatter); // the task runs fine from the command line (php
> symfony acop:dump-email-data [email protected]
> [email protected])
>
>
> }
> }
> }
>
> >
>
--
Regards,
Dheeraj
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---