It works with this code:

try{

      $worker->notifyEventJob($job);

      $configuration =
ProjectConfiguration::getApplicationConfiguration('frontend', 'dev',
false);
      sfContext::createInstance($configuration);
      $configuration->loadHelpers('Partial');

      $inquiry = Doctrine::getTable('Inquiry')->find( $job-
>workload() );

      $email = new emailImmediateReservationEmail( $inquiry );
      $html = get_partial('book/templateBookCustomer', array('inquiry'
=> $inquiry ));
      $email->sendToCustomer($html);

      return $job->sendComplete(true);

    }catch( Exception $e ){

      echo $e->getMessage();

      $job->sendFail( );
    }


Regards,

Nei


On 14 abr, 11:01, Nei Rauni Santos <nra...@gmail.com> wrote:
> Hi,
>
> I found the sfGearmanPlugin very useful and I'm trying to use it, but
> I don't know how to use my swift code to send it in workers.
>
> I'm using sf 1.3 and today I have this code in my actions to send
> emails:
>
>     $this->getLogger()->debug( "SEND TO CUSTOMER ");
>     $email = new emailImmediateReservationEmail($inquiry);
>     $html = $this->getPartial('book/templateBookCustomer',
> array('inquiry' => $inquiry));
>     $email->sendToCustomer($html);
>
> I replaced this code to use gearman
>
>  try{
>       $handle = 
> sfGearmanClient::getInstance()->background('emailImmediateReservationEmailToCustomer',
>  $id);
>
>       var_dump( $handle );
>     }catch( Exception $e ){
>       echo $e->getMessage();
>     }
>
> Here it's ok. The problem that I have is with the worker. I want to
> use my old code in the worker, like this:
>
> class WorkerMail
> {
>   public static function
> emailImmediateReservationEmailToCustomer($job, $worker )
>   {
>     $worker->notifyEventJob($job);
>     try{
>       $inquiry_id = $job->workload();
>       $inquiry = Doctrine::getTable('DInquiry')->find( $inquiry_id );
>       $email = new emailImmediateReservationEmail( $inquiry );
>       $html = $action->getPartial('book/templateBookCustomer',
> array('inquiry' => $inquiry ));
>       $email->sendToCustomer($html);
>       return $job->sendComplete();
>     }catch( Exception $e ){
>       $job->sendFail();
>     }
>   }
>
> }
>
> I must the method getPartial in my worker class, I already tried
> something like this
>
> $action = tools::getInstance()->getActionStack()->getLastEntry();
> $html = $action->getPartial('book/templateBookCustomer',
> array('inquiry' => $inquiry ));
>
> But doesn't work.
>
> Do you have any idea?

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en

Reply via email to