Source of file AjaxControllerExtension.php
Size: 1,036 Bytes - Last Modified: 2021-12-23T10:03:11+00:00
/var/www/docs.ssmods.com/process/src/code/AjaxControllerExtension.php
1234567891011121314151617181920212223242526272829303132333435363738 | <?php /** * Catches errors and returns an AjaxHTTPResponse. * Could also add some helpers to controller for ajax functionality. * In the end this may or may not be needed? * * @author Mark Guinn <mark@adaircreative.com> * @date 04.03.2014 * @package silverstripe-ajax */ class AjaxControllerExtension extends Extension { protected $ajaxResponse; /** * @param int $errorCode * @param SS_HTTPRequest $request */ public function onBeforeHTTPError($errorCode, SS_HTTPRequest $request) { // TODO: This should probably prevent the error page from generating in ajax and possibly return a json response // throw new SS_HTTPResponse_Exception($errorMessage, $errorCode); } /** * @return AjaxHTTPResponse */ public function getAjaxResponse() { if (!isset($this->ajaxResponse)) { $this->ajaxResponse = Injector::inst()->create('AjaxHTTPResponse', $this->owner->getRequest()); } return $this->ajaxResponse; } } |