This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use the new forum.
Home » support » symfony 1.3 and 1.4 » send email from a model class
send email from a model class [message #102495] Wed, 14 July 2010 23:18 Go to previous message
martouf  is currently offline martouf
Messages: 4
Registered: June 2010
Location: Bruxelles
Junior Member
Hi everybody,

I want to send an email everytime the staut of an order is modified in the backend.
I made something like this:
  public function preSave($event)
  {
    $modified = $event->getInvoker()->getModified(true);

    // whether or not the status has changed
    if (isset($modified['statut_id']))
    {

      if ($this->getStatutId() == 2)
      {
        //send email
		$mail = sfContext::getInstance()->getMailer()->compose(); 
		...
      }
    }
  }


I read that it's bad to use sfContext::getInstance() http://webmozarts.com/2009/07/01/why-sfcontextgetinstance-is -bad/.
My questions are:
It is the best way to do what I want?
How can I send email without using sfContext::getInstance() ?
Is there anyway to read a partial from a model class (something like $this->getPartial used in action)

Thanks

Read Message
Read Message
Read Message
Previous Topic:Can $object->getRelation() return a doctrine query ?
Next Topic:Customizing sfDoctrineGuardPlugin error messages
Goto Forum:

  

powered by FUDforum - copyright ©2001-2004 FUD Forum Bulletin Board Software