VuFind API Documentation

ResponseFormatterTraitTest extends TestCase
in package
Uses ResponseFormatterTrait

Class ResponseFormatterTraitTest

Tags
category

VuFind

author

Ere Maijala ere.maijala@helsinki.fi

license

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

link

Main Page

Table of Contents

testAddCorsHeaders()  : void
Test the addCorsHeaders method
testGetJsonResponse()  : void
Test the getJsonResponse method
addCorsHeaders()  : void
Add CORS headers to a response.
getJsonResponse()  : Response
Get a JSON response from an array of data

Methods

testGetJsonResponse()

Test the getJsonResponse method

public testGetJsonResponse() : void
Return values
void

addCorsHeaders()

Add CORS headers to a response.

protected addCorsHeaders(Response $response[, array<string|int, mixed> $allowedMethods = ['GET', 'POST', 'OPTIONS'] ][, array<string|int, mixed> $allowedHeaders = [] ][, string $allowedOrigin = '*' ][, bool $allowCredentials = false ][, int $maxAge = 86400 ]) : void
Parameters
$response : Response

Response

$allowedMethods : array<string|int, mixed> = ['GET', 'POST', 'OPTIONS']

Allowed HTTP methods

$allowedHeaders : array<string|int, mixed> = []

Allowed HTTP headers

$allowedOrigin : string = '*'

Allowed origin (see https://developer.mozilla.org/ en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Origin for details)

$allowCredentials : bool = false

Whether credentials are allowed

$maxAge : int = 86400

Maximum time in seconds the information from a preflight request can be cached

Return values
void

getJsonResponse()

Get a JSON response from an array of data

protected getJsonResponse(array<string|int, mixed> $data[, int $statusCode = 200 ]) : Response
Parameters
$data : array<string|int, mixed>

Data to encode

$statusCode : int = 200

HTTP status code

Return values
Response

Search results