* @package WB * @subpackage ITS */ WBClass::load('WBEvent_Handler' , 'WBEvent_Handler_ITS'); /** * Event_Handler_Stop * * Stop event processing accoding to ticket status * * @version 0.2.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 * * @var array */ protected $config = array( 'status' => array('new', 'closed', 'trash'), 'namespace' => array(), 'loadticket' => '' ); /** * 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; } 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; } }