Ejemplo n.º 1
0
 /**
  * Add session to Google Calendar and update session table with
  * resulting google calendar id.
  *
  * Weird. I have to refresh $subject in order for save() to work!
  *
  * @return void
  */
 public function _postInsert(TA_Model_Observed_Interface $subject, $msg)
 {
     $sessionModel = new Core_Model_Session();
     $subject->refresh();
     $flash = Zend_Controller_Action_HelperBroker::getStaticHelper('FlashMessenger');
     try {
         $googleEvent = new Core_Service_GoogleEvent();
         $subject->gcal_event_id = $googleEvent->insert($sessionModel->getAllSessionDataById($subject->session_id)->toArray());
         // detach the observer otherwise _update gets fired right after this
         $subject::detachStaticObserver($this);
         $subject->save();
     } catch (Exception $e) {
         // Intercept exception so we can fail without halting the application
         $log = Zend_Registry::get('log');
         $log->emerg($e);
         return $flash->addMessage('Something went wrong updating Google Calendar');
     }
     $flash->addMessage('Successfully added session to Google Calendar');
 }