/**
  * If an email reminder is set, then this registers it in the queue.
  */
 protected function onBeforeWrite()
 {
     parent::onBeforeWrite();
     // If an email reminder has been set then register it with the queued
     // jobs module.
     if (class_exists('AbstractQueuedJob') && $this->EmailReminder) {
         $hasJob = $this->ReminderJobID;
         $changedStart = $this->isChanged('RemindDays');
         if ($hasJob) {
             if (!$changedStart) {
                 return;
             } else {
                 $this->ReminderJob()->delete();
             }
         }
         $start = $this->getStartDateTime()->getTimestamp();
         $start = sfTime::subtract($start, $this->RemindDays, sfTime::DAY);
         $job = new EventReminderEmailJob($this);
         $srv = singleton('QueuedJobService');
         $this->ReminderJobID = $srv->queueJob($job, date('Y-m-d H:i:s', $start));
     }
 }