FacturaScripts

APIModel extends APIResourceClass
in package

APIModel is the class for any API Model Resource in Dinamic/Model folder.

Table of Contents

Properties

$method  : string
Contains the HTTP method (GET, PUT, PATCH, POST, DELETE).
$params  : array<string|int, mixed>
$request  : Request
Gives us access to the HTTP request parameters.
$response  : Response
HTTP response object.
$model  : ModelClass
ModelClass object.

Methods

__construct()  : mixed
APIResourceClass constructor.
doDELETE()  : bool
Process the GET request. Overwrite this function to implement is functionality.
doGET()  : bool
Process the GET request. Overwrite this function to implement is functionality.
doPOST()  : bool
Process the POST (create) request. Overwrite this function to implement is functionality.
doPUT()  : bool
Process the PUT (update) request. Overwrite this function to implement is functionality.
getResources()  : array<string|int, mixed>
Returns an associative array with the resources, where the index is the public name of the resource.
processResource()  : bool
Process the model resource, allowing POST/PUT/DELETE/GET ALL actions
setResource()  : array<string|int, mixed>
Register a resource
listAll()  : bool
returnResult()  : void
Return the array with the result, and HTTP_OK status code.
setError()  : void
Return an error message and the corresponding status.
setOk()  : void
Return a order confirmation. For example for a DELETE order.
getResourcesFromFolder()  : array<string|int, mixed>
Load resource map from a folder
getWhereValues()  : array<string|int, DataBaseWhere>
Returns the where clauses.
pluralize()  : string
Convert $text to plural
saveResource()  : bool

Properties

$method

Contains the HTTP method (GET, PUT, PATCH, POST, DELETE).

protected string $method

PUT, PATCH and POST used in the same way.

Methods

__construct()

APIResourceClass constructor.

public __construct(Response $response, Request $request, array<string|int, mixed> $params) : mixed
Parameters
$response : Response
$request : Request
$params : array<string|int, mixed>

doDELETE()

Process the GET request. Overwrite this function to implement is functionality.

public doDELETE() : bool
Return values
bool

doGET()

Process the GET request. Overwrite this function to implement is functionality.

public doGET() : bool
Return values
bool

doPOST()

Process the POST (create) request. Overwrite this function to implement is functionality.

public doPOST() : bool
Return values
bool

doPUT()

Process the PUT (update) request. Overwrite this function to implement is functionality.

public doPUT() : bool
Return values
bool

getResources()

Returns an associative array with the resources, where the index is the public name of the resource.

public getResources() : array<string|int, mixed>
Return values
array<string|int, mixed>

processResource()

Process the model resource, allowing POST/PUT/DELETE/GET ALL actions

public processResource(string $name) : bool
Parameters
$name : string
Return values
bool

setResource()

Register a resource

public setResource(string $name) : array<string|int, mixed>
Parameters
$name : string
Return values
array<string|int, mixed>

listAll()

protected listAll() : bool
Return values
bool

returnResult()

Return the array with the result, and HTTP_OK status code.

protected returnResult(array<string|int, mixed> $data) : void
Parameters
$data : array<string|int, mixed>

setError()

Return an error message and the corresponding status.

protected setError(string $message[, array<string|int, mixed>|null $data = null ][, int $status = Response::HTTP_BAD_REQUEST ]) : void

Can also return an array with additional information.

Parameters
$message : string
$data : array<string|int, mixed>|null = null
$status : int = Response::HTTP_BAD_REQUEST

setOk()

Return a order confirmation. For example for a DELETE order.

protected setOk(string $message[, array<string|int, mixed>|null $data = null ]) : void

Can return an array with additional information.

Parameters
$message : string

is an informative text of the confirmation message

$data : array<string|int, mixed>|null = null

with additional information.

getResourcesFromFolder()

Load resource map from a folder

private getResourcesFromFolder(string $folder) : array<string|int, mixed>
Parameters
$folder : string
Return values
array<string|int, mixed>

getWhereValues()

Returns the where clauses.

private getWhereValues(array<string|int, mixed> $filter, array<string|int, mixed> $operation[, string $defaultOperation = 'AND' ]) : array<string|int, DataBaseWhere>
Parameters
$filter : array<string|int, mixed>
$operation : array<string|int, mixed>
$defaultOperation : string = 'AND'
Return values
array<string|int, DataBaseWhere>

pluralize()

Convert $text to plural

private pluralize(mixed $text) : string
Parameters
$text : mixed
Return values
string

saveResource()

private saveResource() : bool
Return values
bool

        
On this page

Search results