private function sendToEventHandler(array $handler, Event $event) { try { $result = true; $event->addDebugInfo($handler); if (isset($handler["TO_MODULE_ID"]) && !empty($handler["TO_MODULE_ID"]) && $handler["TO_MODULE_ID"] != 'main') { $result = Loader::includeModule($handler["TO_MODULE_ID"]); } elseif (isset($handler["TO_PATH"]) && !empty($handler["TO_PATH"])) { $path = ltrim($handler["TO_PATH"], "/"); if (($path = Loader::getLocal($path)) !== false) { $result = (include_once $path); } } elseif (isset($handler["FULL_PATH"]) && !empty($handler["FULL_PATH"]) && IO\File::isFileExists($handler["FULL_PATH"])) { $result = (include_once $handler["FULL_PATH"]); } $event->addDebugInfo($result); if (isset($handler["TO_METHOD_ARG"]) && is_array($handler["TO_METHOD_ARG"]) && !empty($handler["TO_METHOD_ARG"])) { $args = $handler["TO_METHOD_ARG"]; } else { $args = array(); } if ($handler["VERSION"] > 1) { $args[] = $event; } else { $args = array_merge($args, array_values($event->getParameters())); } $callback = null; if (isset($handler["CALLBACK"])) { $callback = $handler["CALLBACK"]; } elseif (!empty($handler["TO_CLASS"]) && !empty($handler["TO_METHOD"]) && class_exists($handler["TO_CLASS"])) { $callback = array($handler["TO_CLASS"], $handler["TO_METHOD"]); } if ($callback != null) { $result = call_user_func_array($callback, $args); } if ($result != null && !$result instanceof EventResult) { $result = new EventResult(EventResult::UNDEFINED, $result, $handler["TO_MODULE_ID"]); } $event->addDebugInfo($result); if ($result != null) { $event->addResult($result); } } catch (\Exception $ex) { if ($event->isDebugOn()) { $event->addException($ex); } else { throw $ex; } } }