ApiOpenStudio PHPDoc

Api
in package

Class Api

Process REST requests.

Table of Contents

$cache  : Cache
Cache class.
$db  : ADOConnection
DB connection object.
$helper  : ProcessorHelper
Processor helper class.
$logger  : MonologWrapper
Logging class.
$request  : Request
Request object class.
$settings  : array<string|int, mixed>
Config array.
__construct()  : mixed
Api constructor.
getAccept()  : array<string|int, mixed>
Calculate a format from string of header Content-Type or Accept.
process()  : DataContainer
Process the rest request.
cleanData()  : array<string|int, mixed>|string
Utility recursive function to clean vars for processing.
getData()  : Request
Process the request and request header into a meaningful array object.
getMethod()  : string
Utility function to get the REST method from the $_SERVER var.
getOutput()  : mixed
Get the formatted output.
getResource()  : array<string|int, mixed>
Get the requested resource from the DB.
processOutputRemote()  : mixed
Process the output.
processOutputResponse()  : mixed
Process the output and return it in the response.
sortHeadersWeight()  : int
Custom sort function Sort headers by weight.

Properties

$db

DB connection object.

private ADOConnection $db

$request

Request object class.

private Request $request

$settings

Config array.

private array<string|int, mixed> $settings

Methods

__construct()

Api constructor.

public __construct(array<string|int, mixed> $config) : mixed
Parameters
$config : array<string|int, mixed>

Config array.

Tags
throws
ApiException
Return values
mixed

getAccept()

Calculate a format from string of header Content-Type or Accept.

public getAccept([string|null $default = null ]) : array<string|int, mixed>

This is in the format [mimeType, mimeSubType] for use internally.

example: ['mimeType' => 'image', 'mimeSubType' => 'jpeg'] ['mimeType' => 'image', 'mimeSubType' => 'png'] ['mimeType' => 'json', 'mimeSubType' => ''] ['mimeType' => 'xml', 'mimeSubType' => ''] ['mimeType' => 'text', 'mimeSubType' => ''] ['mimeType' => 'html', 'mimeSubType' => '']

Parameters
$default : string|null = null

Default value.

Return values
array<string|int, mixed>

cleanData()

Utility recursive function to clean vars for processing.

private cleanData(mixed $data) : array<string|int, mixed>|string
Parameters
$data : mixed

Variables.

Return values
array<string|int, mixed>|string

getData()

Process the request and request header into a meaningful array object.

private getData() : Request
Tags
throws
ApiException

Invalid request or exception flowing though.

Return values
Request

getMethod()

Utility function to get the REST method from the $_SERVER var.

private getMethod() : string
Tags
throws
ApiException

Throw exception for unexpected headers.

Return values
string

getOutput()

Get the formatted output.

private getOutput(mixed $data, array<string|int, mixed> $meta) : mixed
Parameters
$data : mixed

Data to format.

$meta : array<string|int, mixed>

Resource metadata.

Tags
throws
ApiException
Return values
mixed

getResource()

Get the requested resource from the DB.

private getResource(int $appId, string $method, array<string|int, mixed> $uriParts) : array<string|int, mixed>
Parameters
$appId : int

Request application ID.

$method : string

Request HTTP method.

$uriParts : array<string|int, mixed>

Request URI parts.

Tags
throws
ApiException

Exception flowing through, ot invalid test YAML.

Return values
array<string|int, mixed>

processOutputRemote()

Process the output.

private processOutputRemote(array<string|int, mixed> $meta, mixed $data[, int|null $index = null ]) : mixed
Parameters
$meta : array<string|int, mixed>

Output metadata.

$data : mixed

Response data.

$index : int|null = null

Index in the output array.

Tags
throws
ApiException

Invalid output processor.

Return values
mixed

processOutputResponse()

Process the output and return it in the response.

private processOutputResponse(array<string|int, mixed> $meta, mixed $data[, int $status = 1 ][, int $index = -1 ]) : mixed
Parameters
$meta : array<string|int, mixed>

Output metadata.

$data : mixed

Response data.

$status : int = 1

ApiOpenStudio result status code.

$index : int = -1

Index in the output array.

Tags
throws
ApiException
Return values
mixed

sortHeadersWeight()

Custom sort function Sort headers by weight.

private static sortHeadersWeight(mixed $a, mixed $b) : int
Parameters
$a : mixed

Variable a.

$b : mixed

Variable b.

Return values
int

Search results