/** * Handles an UI event by executing a method associated to the given event * * @param __UIEvent $event The event to handle * @return mixed */ public function handleEvent(__UIEvent &$event) { $return_value = null; //get event info: $component = $event->getComponent(); $event_name = $event->getEventName(); $extra_info = $event->getExtraInfo(); if ($event_name != 'beforeRender' && $event_name != 'afterRender' && $event_name != 'create') { __ComponentHandlerManager::getInstance()->getComponentHandler($this->_view_code)->setDirty(true); } try { //handle an event associated to a component: if ($component != null) { //get component name: $component_name = $component->getName(); //if the component can handle the event, will call to the component event handler if ($component->isEventHandled($event_name)) { $component->handleEvent($event); } //after that, even if the component has handle the event, will execute the event handler method: //1. resolve the concrete handler method: $event_handler_method = $this->_getEventHandlerMethod($event_name, $component_name); //2. call to the concrete handler method: if (method_exists($this, $event_handler_method)) { $return_value = call_user_func(array($this, $event_handler_method), $event); switch (strtoupper($event_name)) { case 'VALIDATE': //first, let's return true if no __ValidationException has been sent $return_value = true; //and reset in case of, any validation component associated to the event's component if (is_array($extra_info) && key_exists('validationRule', $extra_info)) { $validation_rule = __ComponentPool::getInstance()->getComponent($extra_info['validationRule']); $validation_rule->setErrorMessage(null); } break; } } } } catch (__ValidationException $validation_exception) { $return_value = false; //set to false, because a validation exception has been raised if (is_array($extra_info) && key_exists('validationRule', $extra_info)) { $validation_rule = __ComponentPool::getInstance()->getComponent($extra_info['validationRule']); $validation_rule->setErrorMessage($validation_exception->getMessage()); } } return $return_value; }
public function handleEvent(__UIEvent &$event) { $this->_last_response = $this->execute($event->getExtraInfo()); }