- Модуль: rest
- Путь к файлу: ~/bitrix/modules/rest/lib/event/provideroffline.php
- Класс: BitrixRestEventProviderOffline
- Вызов: ProviderOffline::finalize
public function finalize(): void
{
$serverAuthData = $this->getServerAuthData();
$offlineEventsCount = [];
$offlineEventsApp = [];
foreach ($this->eventList as $item)
{
$application = $item['APPLICATION'];
$handler = $item['HANDLER'];
if (
$serverAuthData['client_id'] !== $application['CLIENT_ID']
|| $serverAuthData['auth_connector'] !== $handler['CONNECTOR_ID']
)
{
if (!isset($offlineEventsCount[$application['CLIENT_ID']]))
{
$offlineEventsCount[$application['CLIENT_ID']] = [];
}
if (!isset($offlineEventsCount[$application['CLIENT_ID']][$handler['CONNECTOR_ID']]))
{
$offlineEventsCount[$application['CLIENT_ID']][$handler['CONNECTOR_ID']] = 0;
}
EventOfflineTable::callEvent(
[
'APP_ID' => $application['ID'],
'EVENT_NAME' => $handler['EVENT_NAME'],
'EVENT_DATA' => $item['DATA'],
'EVENT_ADDITIONAL' => $item['AUTH'],
'CONNECTOR_ID' => $handler['CONNECTOR_ID'],
]
);
$offlineEventsCount[$application['CLIENT_ID']][$handler['CONNECTOR_ID']]++;
$offlineEventsApp[$application['ID']] = true;
}
else
{
$logger = LoggerManager::getInstance()->getLogger();
if ($logger)
{
$logger->debug(
"n{delimiter}n"
. "{date} - {host}n{delimiter}n"
. "Event skipped because initializer is current application. n"
. "auth: {serverAuthData}"
. "app: {application}n",
[
'serverAuthData' => $serverAuthData,
'application' => $application,
]
);
}
}
}
if (!empty($offlineEventsCount))
{
$this->notifyApplications($offlineEventsCount);
}
if (!empty($offlineEventsApp))
{
$this->sendOfflineEvent(array_keys($offlineEventsApp));
}
}