28 $logger = LoggerManager::getInstance()->getLogger();
34 .
"{date} - {host}\n{delimiter}\n"
35 .
"Event {eventName} starts. \n{delimiter}\n"
38 'eventName' => $event[
'EVENT'],
39 'arguments' => $arguments,
44 $provider = new \CRestProvider();
45 $description = $provider->getDescription();
47 foreach($description as $scope => $scopeMethods)
50 array_key_exists(\CRestUtil::EVENTS, $scopeMethods)
51 && is_array($scopeMethods[\CRestUtil::EVENTS])
54 foreach($scopeMethods[\CRestUtil::EVENTS] as $key => $restEvent)
56 if($restEvent[0] == $event[
'MODULE_ID'] && toUpper($restEvent[1]) == $event[
'EVENT'])
58 $event[
'EVENT_REST'] = array(
60 'HANDLER' => $restEvent[2],
61 'ADDITIONAL' => array(),
64 if(isset($restEvent[3]) && is_array($restEvent[3]))
66 $event[
'EVENT_REST'][
'ADDITIONAL'] = $restEvent[3];
74 if(array_key_exists(
'EVENT_REST', $event))
80 $handlerFound =
false;
82 if (!empty($arguments[1][
'REST_EVENT_HOLD_EXCEPT_APP']))
87 $appHoldExceptId = $app[
'ID'];
91 if(array_key_exists(
'EVENT_REST', $event))
94 '=EVENT_NAME' => mb_strtoupper($event[
'EVENT_REST'][
'EVENT']),
96 if ($appHoldExceptId > 0)
98 $filter[
'=APP_ID'] = $appHoldExceptId;
101 $dbRes = EventTable::getList(
106 'APP_CODE' =>
'REST_APP.CLIENT_ID',
107 'APP_ACTIVE' =>
'REST_APP.ACTIVE',
108 'APP_INSTALLED' =>
'REST_APP.INSTALLED',
113 $dataProcessed = !is_array($event[
'EVENT_REST'][
'HANDLER']) || !is_callable($event[
'EVENT_REST'][
'HANDLER']);
115 while ($handler = $dbRes->fetch())
117 if (!empty($handler[
'APP_CODE']))
128 .
"{date} - {host}\n{delimiter}\n"
129 .
"Event {eventName} skipped because inactive app: \n"
132 'eventName' => $event[
'EVENT'],
133 'handler' => $handler,
142 if ($appStatus[
'PAYMENT_EXPIRED'] ===
'Y')
148 .
"{date} - {host}\n{delimiter}\n"
149 .
"Event {eventName} skipped because PAYMENT_EXPIRED: \n"
152 'eventName' => $event[
'EVENT'],
153 'appStatus' => $appStatus,
162 $handlerArguments = $arguments;
163 $handlerFound =
true;
169 $handlerArguments = call_user_func_array($event[
'EVENT_REST'][
'HANDLER'], array($handlerArguments, $handler));
170 $call[] = array($handler, $handlerArguments, $event[
'EVENT_REST'][
'ADDITIONAL']);
178 .
"{date} - {host}\n{delimiter}\n"
179 .
"Event {eventName} exception: \n"
180 .
"{errorCode}: {errorMessage}",
182 'eventName' => $event[
'EVENT'],
183 'errorCode' => $e->getCode(),
184 'errorMessage' => $e->getMessage(),
192 $call[] = array($handler, $handlerArguments, $event[
'EVENT_REST'][
'ADDITIONAL']);