public function testGetParameters() { $this->assertEquals(array(), $this->object->getParameters()); $params = array('some param' => 'val', 'k' => 'v'); $event = new Event(null, 'name', $params); $this->assertEquals($params, $event->getParameters()); }
private function sendToEventHandler(array $handler, Event $event) { try { $result = true; $event->addDebugInfo($handler); if (isset($handler["MODULE_ID"]) && !empty($handler["MODULE_ID"])) { $result = Loader::includeModule($handler["MODULE_ID"]); } elseif (isset($handler["PATH"]) && !empty($handler["PATH"])) { $path = ltrim($handler["PATH"], "/"); if ($path = Loader::getLocal($path)) { $result = (include_once $path); } } elseif (isset($handler["INCLUDE_FILE"]) && !empty($handler["INCLUDE_FILE"]) && \Bitrix\Main\IO\File::isFileExists($handler["INCLUDE_FILE"])) { $result = (include_once $handler["INCLUDE_FILE"]); } $event->addDebugInfo($result); if (isset($handler["METHOD_ARG"]) && is_array($handler["METHOD_ARG"]) && count($handler["METHOD_ARG"])) { $args = $handler["METHOD_ARG"]; } else { $args = array(); } if ($handler["VERSION"] > 1) { $args[] = $event; } else { $args = array_merge($args, array_values($event->getParameters())); } $callback = null; if (array_key_exists("CALLBACK", $handler)) { $callback = $handler["CALLBACK"]; } elseif (!empty($handler["CLASS"]) && !empty($handler["METHOD"]) && class_exists($handler["CLASS"])) { $callback = array($handler["CLASS"], $handler["METHOD"]); } if ($callback != null) { $result = call_user_func_array($callback, $args); } if ($result != null && !$result instanceof EventResult) { $result = new EventResult(EventResult::UNDEFINED, $result, $handler["MODULE_ID"]); } $event->addDebugInfo($result); if ($result != null) { $event->addResult($result); } } catch (\Exception $ex) { if ($event->isDebugOn()) { $event->addException($ex); } else { throw $ex; } } }
public function track(Event $event, $uid) { $parameters = $event->getParameters(); $parameters['om_event_type'] = $event->getType(); $this->client->doGet($this->url, $uid, $parameters, $this->timeout); }