private function callWebhooks(Hookable
$event, Context
$context): void
{ /** @var WebhookCollection $webhooksForEvent */
$webhooksForEvent =
$this->
getWebhooks()->
filterForEvent($event->
getName());
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;
}