APIModel
        
        extends APIResourceClass
    
    
            
            in package
            
        
    
    
    
        
            APIModel is the class for any API Model Resource in Dinamic/Model folder.
Tags
Table of Contents
- $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.
 - __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() : mixed
 - Return the array with the result, and HTTP_OK status code.
 - setError() : mixed
 - Return an error message and the corresponding status.
 - setOk() : mixed
 - Return a order confirmation. For example for a DELETE order.
 - toolBox() : ToolBox
 - getRequestArray() : array<string|int, mixed>
 - This method is equivalent to $this->request->get($key, $default), but always return an array, as expected for some parameters like operation, filter or sort.
 - 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.
$params
    protected
        array<string|int, mixed>
    $params
    
    
    
    
$request
Gives us access to the HTTP request parameters.
    protected
        Request
    $request
    
    
    
    
$response
HTTP response object.
    protected
        Response
    $response
    
    
    
    
$model
ModelClass object.
    private
        ModelClass
    $model
    
    
    
    
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>
 
Return values
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) : mixed
    
        Parameters
- $data : array<string|int, mixed>
 
Return values
mixed —setError()
Return an error message and the corresponding status.
    protected
                    setError(string $message[, array<string|int, mixed> $data = null ][, int $status = Response::HTTP_BAD_REQUEST ]) : mixed
        Can also return an array with additional information.
Parameters
- $message : string
 - $data : array<string|int, mixed> = null
 - $status : int = Response::HTTP_BAD_REQUEST
 
Return values
mixed —setOk()
Return a order confirmation. For example for a DELETE order.
    protected
                    setOk(string $message[, array<string|int, mixed> $data = null ]) : mixed
        Can return an array with additional information.
Parameters
- $message : string
 - 
                    
is an informative text of the confirmation message
 - $data : array<string|int, mixed> = null
 - 
                    
with additional information.
 
Return values
mixed —toolBox()
    protected
                    toolBox() : ToolBox
    
    
    
    Tags
Return values
ToolBox —getRequestArray()
This method is equivalent to $this->request->get($key, $default), but always return an array, as expected for some parameters like operation, filter or sort.
    private
                    getRequestArray(string $key[, string $default = '' ]) : array<string|int, mixed>
    
        Parameters
- $key : string
 - $default : string = ''
 
Return values
array<string|int, mixed> —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( $text) : string
    
        Parameters
Return values
string —saveResource()
    private
                    saveResource() : bool