Added backend.ajax.beforeRunHandler event

This commit is contained in:
Luke Towers 2018-10-14 10:32:47 -06:00
parent 48626a44a1
commit 2c82b05062
1 changed files with 33 additions and 0 deletions

View File

@ -498,6 +498,39 @@ class Controller extends Extendable
*/
protected function runAjaxHandler($handler)
{
/**
* @event backend.ajax.beforeRunHandler
* 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('backend.ajax.beforeRunHandler', function((\Backend\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);
* }
* }
* });
*
*/
if ($event = $this->fireSystemEvent('backend.ajax.beforeRunHandler', [$handler])) {
return $event;
}
/*
* Process Widget handler
*/