Added more inline API event docs:
Added docs for: cms.component.beforeRunAjaxHandler cms.component.runAjaxHandler Improved docs for: cms.ajax.beforeRunHandler
This commit is contained in:
parent
1c7b311ea9
commit
1032fd0cc1
|
|
@ -153,8 +153,34 @@ abstract class ComponentBase extends Extendable
|
|||
*/
|
||||
public function runAjaxHandler($handler)
|
||||
{
|
||||
/*
|
||||
* Extensibility
|
||||
/**
|
||||
* @event cms.component.beforeRunAjaxHandler
|
||||
* 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, '::')) {
|
||||
* list($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, '::')) {
|
||||
* list($componentAlias, $handlerName) = explode('::', $handler);
|
||||
* if ($componentAlias === $this->getBackendWidgetAlias()) {
|
||||
* return $this->backendControllerProxy->runAjaxHandler($handler);
|
||||
* }
|
||||
* }
|
||||
* });
|
||||
*
|
||||
*/
|
||||
if ($event = $this->fireSystemEvent('cms.component.beforeRunAjaxHandler', [$handler])) {
|
||||
return $event;
|
||||
|
|
@ -162,8 +188,28 @@ abstract class ComponentBase extends Extendable
|
|||
|
||||
$result = $this->$handler();
|
||||
|
||||
/*
|
||||
* Extensibility
|
||||
/**
|
||||
* @event 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);
|
||||
* }
|
||||
* });
|
||||
*
|
||||
*/
|
||||
if ($event = $this->fireSystemEvent('cms.component.runAjaxHandler', [$handler, $result])) {
|
||||
return $event;
|
||||
|
|
|
|||
|
|
@ -688,23 +688,34 @@ class Controller
|
|||
protected function runAjaxHandler($handler)
|
||||
{
|
||||
/**
|
||||
* @event cms.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):
|
||||
*
|
||||
* $this->controller->bindEvent('ajax.beforeRunHandler', function ($handler) {
|
||||
* if (strpos($handler, '::')) {
|
||||
* list($componentAlias, $handlerName) = explode('::', $handler);
|
||||
* if ($componentAlias === $this->getBackendWidgetAlias()) {
|
||||
* return $this->backendControllerProxy->runAjaxHandler($handler);
|
||||
* }
|
||||
* }
|
||||
* });
|
||||
*
|
||||
*/
|
||||
* @event cms.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('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);
|
||||
* }
|
||||
* }
|
||||
* });
|
||||
*
|
||||
*/
|
||||
if ($event = $this->fireSystemEvent('cms.ajax.beforeRunHandler', [$handler])) {
|
||||
return $event;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue