|
pclib
3.3.0
Lightweight PHP framework
|
Controller for the application REST API with bearer authorisation, post/get methods, returning json. More...
Public Member Functions | |
| run ($action) | |
| Call action method of the controller, feeding it with required parameters. More... | |
| getToken () | |
| Return authorisation token from request Authorization header. More... | |
| error ($message, $httpStatus=500,... $args) | |
| Exit with http status code and json message. More... | |
Public Member Functions inherited from Controller | |
| init () | |
| Called before every action. More... | |
| action ($rs) | |
| Call route $rs and return result of the controller's action. More... | |
| template ($path, $data=[]) | |
| Create template $path, populated with $data. More... | |
| redirect ($route) | |
| Redirect to $route. | |
| model ($tableName, $id=null) | |
| Return model for table $tableName. | |
| selection ($from=null) | |
| Return orm\Selection class. | |
| authorize ($perm='') | |
| Check if user has permission $perm. More... | |
| outputJson (array $data, $code='') | |
| Output json data and exit. More... | |
Public Member Functions inherited from BaseObject | |
| loadDefaults ($className=null) | |
| Load default parameters of class $className into object instance. | |
| setProperties (array $defaults) | |
| Set public properties of object from the array. More... | |
| toArray () | |
| Convert object to array. More... | |
Data Fields | |
| $publicMethods = [] | |
| List of public methods. More... | |
| $publicApi = false | |
| Set if whole controller is public - do not use athorisation. | |
Data Fields inherited from Controller | |
| $name | |
| Name of the controller without postfix. | |
| $action | |
| Name of the called action without postfix. | |
| $authorizeRedirect = 'user/signin' | |
| authorize() fallback when user is not logged in. | |
| $allowDashInAction = true | |
| Convert url action some-thing into someThingAction() call. | |
Data Fields inherited from BaseObject | |
| $serviceLocator | |
| var function() Return service object when requested with service(). | |
Protected Attributes | |
| $token | |
| var system\AuthToken | |
| $request | |
| var Request | |
Protected Attributes inherited from Controller | |
| $app | |
| var App Link to application | |
| $ACTION_POSTFIX = 'Action' | |
| Each action method name must have following postfix. More... | |
Additional Inherited Members | |
Static Public Member Functions inherited from BaseObject | |
| static | defaults (... $args) |
| Set or retireve default parameters of the object. More... | |
Protected Member Functions inherited from BaseObject | |
| service ($service, $default=null) | |
| Try acquire $service and load it into property $this->$service. More... | |
Controller for the application REST API with bearer authorisation, post/get methods, returning json.
Create your REST controllers as ancestors of ApiController.
| error | ( | $message, | |
$httpStatus = 500, |
|||
| $args | |||
| ) |
Exit with http status code and json message.
| string | $message | |
| int | $httpStatus |
Reimplemented from Controller.
| getToken | ( | ) |
Return authorisation token from request Authorization header.
| run | ( | $action | ) |
Call action method of the controller, feeding it with required parameters.
| Action | $action | called action. |
Reimplemented from Controller.
| $publicMethods = [] |
List of public methods.
Non-public methods without valid token will be rejected.