public function postTransactionCommit(Doctrine_Event $event) { Event::run('telephony.postTransactionCommit', Bluebox_Record::getBaseTransactionObject()); // A transaction just ended - we write out any configuration information set by the telephony driver now. // THIS IS WHERE WE UPDATE VIA THE SWITCH-SPECIFIC DRIVER! if (Kohana::config('telephony.driver') && Kohana::config('telephony.diskoutput')) { if (!empty(self::$changedModels)) { Kohana::log('debug', 'Telephony -> Creating config from saved models in memory.'); foreach (self::$changedModels as $change) { Kohana::log('debug', 'Telephony -> Preparing to generate configurartion from ' . $change['action'] . ' of ' . get_class($change['record']) . ' ' . implode(', ', $change['identifier']) . ' with OID ' . $change['record']->getOid() . ' on base model ' . get_class($change['baseModel'])); } // Figure out what models were touched and either set or delete based on the action that was done to them // NOTE: Make sure this occurs in the same order it occurred via Doctrine's transaction foreach (self::$changedModels as $change) { if (!empty($change['baseModel'])) { Bluebox_Record::setBaseSaveObject($change['baseModel']); } else { Kohana::log('alert', 'Telephony -> The record ' . get_class($change['record']) . ' did not have the baseModel set!'); continue; } switch ($change['action']) { case 'update': case 'insert': Telephony::set($change['record'], $change['identifier']); break; case 'delete': Telephony::delete($change['record'], $change['identifier']); break; default: Kohana::log('debug', 'An unknown action (' . $change['action'] . ') was performed on model ' . get_class($change['record'])); break; } } self::$changedModels = array(); Telephony::save(); // If configured, tell the telephony engine to reload it's configs immediately Telephony::commit(); // Clear the telephony info in memory. This is important, because if someone is doing a bulk add or otherwise, things get crazy Telephony::reset(); } } }