* @license PHP License * @package WB * @subpackage base */ WBClass::load('WBEvent_Handler'); /** * Event_Handler_ITS * * An empty event handler * * @version 0.1.0 * @package WB * @subpackage base */ class WBEvent_Handler_ITS extends WBEvent_Handler { /** * handler config * * Parameters: * - "loadticket": index of id to load ticket * * @var array */ protected $config = array( 'loadticket' => '' ); /** * @var WBITS_Ticket */ protected $ticket; /** * Load ticket data, if neccessary * * Use config parameter "loadticket" as ticket id * @param WBEvent $e * @param bool $merge merge ticket data with event date */ protected function loadTicket($e, $merge = true) { // no need to load if (empty($this->config['loadticket'])) { return; } // load ticket data $tid = $e->get($this->config['loadticket']); if (empty($tid)) { $ex = array( 'msg' => 'loadticket failed - ticket id is empty', 'code' => 1, 'class' => __CLASS__ ); throw WBClass::create('WBException_Config', $ex); } $this->ticket = WBClass::create('WBITS_Ticket'); $this->ticket->loadById($tid); $oid = $this->ticket->getObscureId(); if (empty($oid)) { $ex = array( 'msg' => 'loadticket failed ticket not found', 'code' => 2, 'class' => __CLASS__ ); throw WBClass::create('WBException_Config', $ex); } if (!$merge) { return; } $tData = $this->ticket->getData(); // add ticket data to event foreach ($tData as $k => $v) { $e->set($k, $v); } } }