if ($webhooksForEvent->
count() === 0
) { return;
} $affectedRoleIds =
$webhooksForEvent->
getAclRoleIdsAsBinary();
$languageId =
$context->
getLanguageId();
$userLocale =
$this->
getAppLocaleProvider()->
getLocaleFromContext($context);
// If the admin worker is enabled we send all events synchronously, as we can't guarantee timely delivery otherwise.
// Additionally, all app lifecycle events are sent synchronously as those can lead to nasty race conditions otherwise.
if ($this->isAdminWorkerEnabled ||
$event instanceof AppDeletedEvent ||
$event instanceof AppChangedEvent
) { Profiler::
trace('webhook::dispatch-sync',
function D
) use ($userLocale,
$languageId,
$affectedRoleIds,
$event,
$webhooksForEvent): void
{ $this->
callWebhooksSynchronous($webhooksForEvent,
$event,
$affectedRoleIds,
$languageId,
$userLocale);
});
return;
} Profiler::
trace('webhook::dispatch-async',
function D
) use ($userLocale,
$languageId,
$affectedRoleIds,
$event,
$webhooksForEvent): void
{ $this->
dispatchWebhooksToQueue($webhooksForEvent,
$event,
$affectedRoleIds,
$languageId,
$userLocale);
});
}