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  : Config
Config class.
$test  : bool
Test for resource direct from file.
__construct()  : mixed
Api constructor.
getAccept()  : bool|string
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.
crawlMeta()  : mixed
Process the meta data, using depth first iteration.
getCache()  : bool
Check cache for any results.
getCacheKey()  : string
Get the cache key for a request.
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>|Resource
Get the requested resource from the DB.
processOutputRemote()  : void
Process the output.
processOutputResponse()  : mixed
Process the output and return 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

$test

Test for resource direct from file.

private bool $test = false

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([mixed $default = null ]) : bool|string
Parameters
$default : mixed = null

Default value.

Return values
bool|string

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

crawlMeta()

Process the meta data, using depth first iteration.

private crawlMeta(mixed $meta) : mixed
Parameters
$meta : mixed

The resource metadata.

Tags
throws
ApiException

Let any exceptions flow through.

Return values
mixed

getCache()

Check cache for any results.

private getCache(string $cacheKey) : bool
Parameters
$cacheKey : string

Cache key.

Tags
throws
ApiException

Allow any exceptions to flow through.

Return values
bool

getCacheKey()

Get the cache key for a request.

private getCacheKey(array<string|int, mixed> $uriParts) : string
Parameters
$uriParts : array<string|int, mixed>

Array of UTI fragments.

Tags
throws
ApiException
Return values
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

Thow exception for unexpected headers.

Return values
string

getOutput()

Get the formatted output.

private getOutput(mixed $data) : mixed
Parameters
$data : mixed

Data to format.

Tags
throws
ApiException

Let any exceptions flow through.

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>|Resource
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>|Resource

processOutputRemote()

Process the output.

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

Output mnetadata.

$data : mixed

Response data.

$index : int|null = null

Index in the output array.

Tags
throws
ApiException

Invalid output processor.

Return values
void

processOutputResponse()

Process the output and return in the response.

private processOutputResponse(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

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