Ubiquity 2.5.2
php rapid development framework
|
Abstract base class for Rest controllers. More...
Public Member Functions | |
__construct () | |
Constructor initialize $view variable. | |
index () | |
Default action. | |
isValid ($action) | |
Returns True if access to the controller is allowed To be override in sub classes. | |
onInvalidControl () | |
Called if isValid () returns false To be override in sub classes. | |
connect () | |
Realize the connection to the server. | |
initialize () | |
Method called before each action Can be override in derived class. | |
finalize () | |
Method called after each action Can be override in derived class. | |
_errorHandler ($e) | |
_setResponseCode ($value) | |
_get ($condition='1=1', $include=false, $useCache=false) | |
Returns a list of objects from the server. | |
_getAll () | |
Returns all the instances from the model $resource. | |
_getOne ($keyValues, $include=false, $useCache=false) | |
Get the first object corresponding to the $keyValues. | |
_format ($arrayMessage) | |
_getManyToOne ($ids, $member, $include=false, $useCache=false) | |
_getOneToMany ($ids, $member, $include=false, $useCache=false) | |
_getManyToMany ($ids, $member, $include=false, $useCache=false) | |
_update (... $keyValues) | |
Update an instance of $model selected by the primary key $keyValues Require members values in $_POST array. | |
_add () | |
Insert a new instance of $model Require members values in $_POST array. | |
_getRelationShip ($id, $member) | |
Returns an associated member value(s). | |
_delete (... $keyValues) | |
Delete the instance of $model selected by the primary key $keyValues. | |
Public Member Functions inherited from Controller | |
loadView (string $viewName, $pData=null, bool $asString=false) | |
Loads the view $viewName possibly passing the variables $pdata. | |
loadDefaultView ($pData=null, bool $asString=false) | |
Loads the default view (controllerName/actionName) possibly passing the variables $pdata. | |
getDefaultViewName () | |
Returns the default view name for this controller/action i.e ControllerName/actionName.html for the action actionName in ControllerName If there is an activeTheme @activeTheme/ControllerName/actionName.html | |
forward (string $controller, string $action='index', $params=[], bool $initialize=false, bool $finalize=false) | |
Loads the controller $controller and calls its $action method by passing the parameters $params. | |
redirectToRoute (string $routeName, $parameters=[], bool $initialize=false, bool $finalize=false) | |
Redirect to a route by its name. | |
getView () | |
Returns the associated view instance. | |
Public Member Functions inherited from RestControllerUtilitiesTrait | |
_validateInstance ($instance, $members, $excludedValidators=[]) | |
Static Public Member Functions | |
static | _getApiVersion () |
static | _getTemplateFile () |
Returns the template for creating this type of controller. | |
Protected Member Functions | |
checkPermissions ($action, $datas=null) | |
To override in derived classes. | |
requireAuth ($action) | |
Returns true if $action require an authentification with token. | |
refreshToken () | |
Refresh an active token. | |
Protected Member Functions inherited from RestControllerUtilitiesTrait | |
getDatas () | |
getRequestParam ($param, $default) | |
operate_ ($instance, $callback, $status, $exceptionMessage, $keyValues) | |
generatePagination (&$filter, $pageNumber, $pageSize) | |
updateOperation ($instance, $datas, $updateMany=false) | |
addOperation ($instance, $datas, $insertMany=false) | |
_getResponseFormatter () | |
getResponseFormatter () | |
To override, returns the active formatter for the response. | |
_getRequestFormatter () | |
getRequestFormatter () | |
To override, returns the active formatter for the request. | |
_getRestServer () | |
getRestServer () | |
To override, returns the active RestServer. | |
_setValuesToObject ($instance, $values=[]) | |
Updates $instance with $values To eventually be redefined in derived classes. | |
updateManyToOne ($manyToOneRelations, $members, $className, $instance, $values) | |
getInclude ($include) | |
addError ($code, $title, $detail=null, $source=null, $status=null) | |
hasErrors () | |
displayErrors () | |
getAssociatedMemberValues_ ($ids, $getDatas, $member, $include=false, $useCache=false, $multiple=true) | |
addViolation (ConstraintViolation $violation) | |
getPrimaryKeysFromDatas ($datas, $model) | |
getCondition ($condition) | |
Protected Attributes | |
$config | |
$model | |
$contentType | |
$restCache | |
$useValidation = true | |
$responseFormatter | |
$requestFormatter | |
$server | |
Protected Attributes inherited from Controller | |
View | $view |
Protected Attributes inherited from RestControllerUtilitiesTrait | |
$errors | |
Abstract base class for Rest controllers.
Ubiquity\controllers\rest$RestController This class is part of Ubiquity
Definition at line 25 of file RestBaseController.php.
__construct | ( | ) |
Constructor initialize $view variable.
Reimplemented from Controller.
Definition at line 50 of file RestBaseController.php.
_add | ( | ) |
Insert a new instance of $model Require members values in $_POST array.
Definition at line 278 of file RestBaseController.php.
_delete | ( | $keyValues | ) |
Delete the instance of $model selected by the primary key $keyValues.
array | $keyValues |
Definition at line 326 of file RestBaseController.php.
_errorHandler | ( | $e | ) |
Definition at line 138 of file RestBaseController.php.
_format | ( | $arrayMessage | ) |
Definition at line 210 of file RestBaseController.php.
_get | ( | $condition = '1=1' , |
|
$include = false , |
|||
$useCache = false |
|||
) |
Returns a list of objects from the server.
string | $condition | the sql Where part |
boolean | string | $include | if true, loads associate members with associations, if string, example : client.*,commands |
boolean | $useCache |
Definition at line 154 of file RestBaseController.php.
_getAll | ( | ) |
Returns all the instances from the model $resource.
Query parameters:
Definition at line 175 of file RestBaseController.php.
|
static |
Reimplemented in JsonRestController, and JsonApiRestController.
Definition at line 333 of file RestBaseController.php.
_getManyToMany | ( | $ids, | |
$member, | |||
$include = false , |
|||
$useCache = false |
|||
) |
string | $ids | |
string | $member | |
string | boolean | $include | if true, loads associate members with associations, if string, example : client.*,commands |
boolean | $useCache |
Exception
Definition at line 249 of file RestBaseController.php.
_getManyToOne | ( | $ids, | |
$member, | |||
$include = false , |
|||
$useCache = false |
|||
) |
string | $ids | |
string | $member | |
string | boolean | $include | if true, loads associate members with associations, if string, example : client.*,commands |
boolean | $useCache |
Definition at line 221 of file RestBaseController.php.
_getOne | ( | $keyValues, | |
$include = false , |
|||
$useCache = false |
|||
) |
Get the first object corresponding to the $keyValues.
string | $keyValues | primary key(s) value(s) or condition |
boolean | string | $include | if true, loads associate members with associations, if string, example : client.*,commands |
boolean | $useCache | if true then response is cached |
Definition at line 195 of file RestBaseController.php.
_getOneToMany | ( | $ids, | |
$member, | |||
$include = false , |
|||
$useCache = false |
|||
) |
string | $ids | |
string | $member | |
string | boolean | $include | if true, loads associate members with associations, if string, example : client.*,commands |
boolean | $useCache |
Exception
Definition at line 235 of file RestBaseController.php.
_getRelationShip | ( | $id, | |
$member | |||
) |
Returns an associated member value(s).
Query parameters:
string | $id | The primary key value(s), if the primary key is composite, use a comma to separate the values (e.g. 1,115,AB) |
string | $member | The member to load |
Definition at line 303 of file RestBaseController.php.
|
static |
Returns the template for creating this type of controller.
Reimplemented in JsonRestController, JsonApiRestController, and RestResourceController.
Definition at line 342 of file RestBaseController.php.
_setResponseCode | ( | $value | ) |
Reimplemented from RestControllerUtilitiesTrait.
Definition at line 143 of file RestBaseController.php.
_update | ( | $keyValues | ) |
Update an instance of $model selected by the primary key $keyValues Require members values in $_POST array.
array | $keyValues |
Definition at line 261 of file RestBaseController.php.
|
protected |
To override in derived classes.
Check if the datas in the authorization token allows access to the action. If the token is expired, this method is not used.
$action | ||
mixed | $datas | datas in authorization token |
Definition at line 90 of file RestBaseController.php.
connect | ( | ) |
Realize the connection to the server.
To override in derived classes to define your own authentication
Definition at line 115 of file RestBaseController.php.
finalize | ( | ) |
Method called after each action Can be override in derived class.
Reimplemented from Controller.
Definition at line 133 of file RestBaseController.php.
index | ( | ) |
Default action.
Reimplemented from Controller.
Definition at line 65 of file RestBaseController.php.
initialize | ( | ) |
Method called before each action Can be override in derived class.
Reimplemented from Controller.
Reimplemented in RestResourceController.
Definition at line 130 of file RestBaseController.php.
isValid | ( | $action | ) |
Returns True if access to the controller is allowed To be override in sub classes.
string | $action |
Reimplemented from Controller.
Definition at line 70 of file RestBaseController.php.
onInvalidControl | ( | ) |
Called if isValid () returns false To be override in sub classes.
Reimplemented from Controller.
Definition at line 107 of file RestBaseController.php.
|
protected |
Refresh an active token.
Ubiquity\exceptions\RestException
Definition at line 125 of file RestBaseController.php.
|
protected |
Returns true if $action require an authentification with token.
string | $action |
Definition at line 100 of file RestBaseController.php.
|
protected |
Definition at line 27 of file RestBaseController.php.
|
protected |
Definition at line 29 of file RestBaseController.php.
|
protected |
Definition at line 28 of file RestBaseController.php.
|
protected |
Definition at line 42 of file RestBaseController.php.
|
protected |
Definition at line 37 of file RestBaseController.php.
|
protected |
Definition at line 30 of file RestBaseController.php.
|
protected |
Definition at line 48 of file RestBaseController.php.
|
protected |
Definition at line 31 of file RestBaseController.php.