VuFind API Documentation

AjaxResponseTrait

Trait to allow AJAX response generation.

Dependencies:

  • \VuFind\I18n\Translator\TranslatorAwareTrait
  • Injection of $this->ajaxManager (for some functionality)
Tags
category

VuFind

author

Chris Hallberg challber@villanova.edu

license

http://opensource.org/licenses/gpl-2.0.php GNU General Public License

link

Wiki

Table of Contents

$ajaxManager  : PluginManager
AJAX Handler plugin manager
callAjaxMethod()  : Response
Call an AJAX method and turn the result into a response.
formatContent()  : string
Format the content of the AJAX response based on the response type.
getAjaxResponse()  : Response
Send output data and exit.
getExceptionResponse()  : Response
Turn an exception into error response.

Properties

Methods

callAjaxMethod()

Call an AJAX method and turn the result into a response.

protected callAjaxMethod(string $method[, string $type = 'application/json' ]) : Response
Parameters
$method : string

AJAX method to call

$type : string = 'application/json'

Content type to output

Return values
Response

formatContent()

Format the content of the AJAX response based on the response type.

protected formatContent(string $type, mixed $data, int $httpCode) : string
Parameters
$type : string

Content-type of output

$data : mixed

The response data

$httpCode : int

A custom HTTP Status Code

Tags
throws
Exception
Return values
string

getAjaxResponse()

Send output data and exit.

protected getAjaxResponse(string $type, mixed $data[, int $httpCode = null ]) : Response
Parameters
$type : string

Content type to output

$data : mixed

The response data

$httpCode : int = null

A custom HTTP Status Code

Tags
throws
Exception
Return values
Response

getExceptionResponse()

Turn an exception into error response.

protected getExceptionResponse(string $type, Exception $e) : Response
Parameters
$type : string

Content type to output

$e : Exception

Exception to output.

Return values
Response

Search results