cms.component.runAjaxHandler

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

The parameters provided are $handler (the requested AJAX handler to be run) and $result (the result of the component processing the request)

Example usage (Logs requests and their response):

Event::listen('cms.component.beforeRunHandler', function ((\Cms\Classes\ComponentBase) $component, (string) $handler, (mixed) $result) {
    if (in_array($handler, $interceptHandlers)) {
        return 'request has been intercepted, original response: ' . json_encode($result);
    }
});

Or

$this->controller->bindEvent('componenet.beforeRunAjaxHandler', function ((string) $handler, (mixed) $result) {
    if (in_array($handler, $interceptHandlers)) {
        return 'request has been intercepted, original response: ' . json_encode($result);
    }
});

Usage

Triggers

Class or file Line
Cms\Classes\ComponentBase 218
Copyright © 2024 Winter CMS