cms.ajax.beforeRunHandler

Triggered in Cms\Classes\Controller.

Provides an opportunity to modify an AJAX request

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

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

Event::listen('cms.ajax.beforeRunHandler', function((\Cms\Classes\Controller) $controller, (string) $handler) {
    if (strpos($handler, '::')) {
        list($componentAlias, $handlerName) = explode('::', $handler);
        if ($componentAlias === $this->getBackendWidgetAlias()) {
            return $this->backendControllerProxy->runAjaxHandler($handler);
        }
    }
});

Or

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