cms.component.beforeRunAjaxHandler

Triggered in Cms\Classes\ComponentBase.

Provides an opportunity to modify an AJAX request to a component before it is processed by the component

The parameter provided is $handler (the requested AJAX handler to be run)

Example usage (forwards AJAX handlers to a backend widget):

Event::listen('cms.component.beforeRunAjaxHandler', function ((\Cms\Classes\ComponentBase) $component, (string) $handler) {
    if (strpos($handler, '::')) {
        [$componentAlias, $handlerName] = explode('::', $handler);
        if ($componentAlias === $this->getBackendWidgetAlias()) {
            return $this->backendControllerProxy->runAjaxHandler($handler);
        }
    }
});

Or

$this->controller->bindEvent('component.beforeRunAjaxHandler', function ((string) $handler) {
    if (strpos($handler, '::')) {
        [$componentAlias, $handlerName] = explode('::', $handler);
        if ($componentAlias === $this->getBackendWidgetAlias()) {
            return $this->backendControllerProxy->runAjaxHandler($handler);
        }
    }
});