* @author Maxim Aisel * @package WB * @subpackage ITS */ WBClass::load('WBEvent_Handler' , 'WBEvent_Handler_ITS'); /** * Event_Handler_Stop * * Stop event processing accoding to ticket status * * @version 0.3.0 * @package WB * @subpackage ITS */ class WBEvent_Handler_ITS_Stop extends WBEvent_Handler_ITS { /** * Handler Config * * Parameters: * - "status": List of status to stop * - "namespace": List of namespaces to stop * - "loadticket": index of id to load ticket * - "ticscopeid": List of scopeid to stop * * @var array */ protected $config = array( 'status' => array('new', 'closed', 'trash'), 'namespace' => array(), 'loadticket' => '', 'ticscopeid' => array() ); /** * Process Event * * Stop processing if status is one on config * * @see isRecoverable() * @param WBEvent $e * @return bool true to continue, false to stop processing * @throws Exception in case of error */ public function process(WBEvent $e) { $this->loadTicket($e); $res = $this->check($e->get('status'), $this->config['status']); if (!$res) { $this->debugPrint('Stop because status did not match'); return false; } $res = $this->check($e->get('namespace'), $this->config['namespace']); if (!$res) { $this->debugPrint('Stop because namespace did not match'); return false; } $res = $this->check($e->get('ticscopeid'), $this->config['ticscopeid']); if (!$res) { $this->debugPrint('Stop because ticscopeid did not match'); return false; } return true; } /** * Check for value * * See if value is in list of denied values * * @param string $value * @param array $denied */ private function check($value, $denied) { if (empty($denied)) { return true; } if (!is_array($denied)) { $denied = array($denied); } if (in_array($value, $denied)) { return false; } return true; } }