Ubiquity  2.0.2
php rapid development framework
RestController Class Reference
+ Inheritance diagram for RestController:

Public Member Functions

 __construct ()
 
 isValid ()
 
 onInvalidControl ()
 
 connect ()
 Realise the connection to the server To override in derived classes to define your own authentication. More...
 
 initialize ()
 
 finalize ()
 
 _errorHandler ($e)
 
 _setResponseCode ($value)
 
 index ()
 Returns all objects for the resource $model ("cache"=>false) More...
 
 getById ($id)
 Default route for requiring a single object ("{id}","methods"=>["get","options"]) More...
 
 get ($condition="1=1", $loadManyToOne=false, $loadOneToMany=false, $useCache=false)
 Returns a list of objects from the server. More...
 
 getOne ($keyValues, $loadManyToOne=false, $loadOneToMany=false, $useCache=false)
 Get the first object corresponding to the $keyValues. More...
 
 _format ($arrayMessage)
 
 getOneToMany ($member, $useCache=false)
 
 getManyToMany ($member, $useCache=false)
 
 update (... $keyValues)
 Update an instance of $model selected by the primary key $keyValues Require members values in $_POST array. More...
 
 add ()
 Insert a new instance of $model Require members values in $_POST array . More...
 
 delete (... $keyValues)
 Delete the instance of $model selected by the primary key $keyValues Requires an authorization with access token. More...
 
- Public Member Functions inherited from Controller
 index ()
 Default action. More...
 
 __construct ()
 Constructor
Automatically invokes the isValid () method to check if access is allowed. More...
 
 initialize ()
 Method called before each action Can be override in derived class. More...
 
 finalize ()
 Method called after each action Can be override in derived class. More...
 
 loadView ($viewName, $pData=NULL, $asString=false)
 Loads the view $viewName possibly passing the variables $pdata. More...
 
 isValid ()
 Returns True if access to the controller is allowed To be override in sub classes. More...
 
 onInvalidControl ()
 Called if isValid () returns false
To be override in sub classes. More...
 
 forward ($controller, $action="index", $params=array(), $initialize=false, $finalize=false)
 Loads the controller $controller and calls its $action method by passing the parameters $params. More...
 
 redirectToRoute ($routeName, $parameters=[], $initialize=false, $finalize=false)
 Redirect to a route by its name. More...
 

Protected Member Functions

 connectDb ($config)
 
 _setValuesToObject ($instance, $values=null)
 Updates $instance with $values To eventually be redefined in derived classes. More...
 

Protected Attributes

 $config
 
 $model
 
 $contentType
 
 $restCache
 
 $responseFormatter
 
 $server
 
- Protected Attributes inherited from Controller
 $view
 

Detailed Description

Author
jc Abstract base class for Rest controllers

Definition at line 17 of file RestController.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( )

Definition at line 32 of file RestController.php.

Member Function Documentation

◆ _errorHandler()

_errorHandler (   $e)

Definition at line 85 of file RestController.php.

◆ _format()

_format (   $arrayMessage)

Definition at line 178 of file RestController.php.

◆ _setResponseCode()

_setResponseCode (   $value)

Definition at line 93 of file RestController.php.

◆ _setValuesToObject()

_setValuesToObject (   $instance,
  $values = null 
)
protected

Updates $instance with $values To eventually be redefined in derived classes.

Parameters
object$instancethe instance to update
array | null$values

Definition at line 110 of file RestController.php.

◆ add()

add ( )

Insert a new instance of $model Require members values in $_POST array .

Definition at line 239 of file RestController.php.

◆ connect()

connect ( )

Realise the connection to the server To override in derived classes to define your own authentication.

Definition at line 63 of file RestController.php.

◆ connectDb()

connectDb (   $config)
protected

Definition at line 97 of file RestController.php.

◆ delete()

delete (   $keyValues)

Delete the instance of $model selected by the primary key $keyValues Requires an authorization with access token.

Parameters
array$keyValues("methods"=>["delete"])

Definition at line 263 of file RestController.php.

◆ finalize()

finalize ( )

Definition at line 78 of file RestController.php.

◆ get()

get (   $condition = "1=1",
  $loadManyToOne = false,
  $loadOneToMany = false,
  $useCache = false 
)

Returns a list of objects from the server.

Parameters
string$conditionthe sql Where part
boolean$loadManyToOne
boolean$loadOneToMany
boolean$useCache

Definition at line 141 of file RestController.php.

◆ getById()

getById (   $id)

Default route for requiring a single object ("{id}","methods"=>["get","options"])

Definition at line 130 of file RestController.php.

◆ getManyToMany()

getManyToMany (   $member,
  $useCache = false 
)
Parameters
string$member
boolean$useCache
Exceptions

Definition at line 202 of file RestController.php.

◆ getOne()

getOne (   $keyValues,
  $loadManyToOne = false,
  $loadOneToMany = false,
  $useCache = false 
)

Get the first object corresponding to the $keyValues.

Parameters
string$keyValuesprimary key(s) value(s) or condition
boolean$loadManyToOneif true then manyToOne members are loaded.
boolean$loadOneToManyif true then oneToMany members are loaded.
boolean$useCacheif true then response is cached

Definition at line 162 of file RestController.php.

◆ getOneToMany()

getOneToMany (   $member,
  $useCache = false 
)
Parameters
string$member
boolean$useCache
Exceptions

Definition at line 187 of file RestController.php.

◆ index()

index ( )

Returns all objects for the resource $model ("cache"=>false)

Definition at line 121 of file RestController.php.

◆ initialize()

initialize ( )

Definition at line 67 of file RestController.php.

◆ isValid()

isValid ( )

Definition at line 46 of file RestController.php.

◆ onInvalidControl()

onInvalidControl ( )

Definition at line 55 of file RestController.php.

◆ update()

update (   $keyValues)

Update an instance of $model selected by the primary key $keyValues Require members values in $_POST array.

Parameters
array$keyValues

Definition at line 218 of file RestController.php.

Field Documentation

◆ $config

$config
protected

Definition at line 18 of file RestController.php.

◆ $contentType

$contentType
protected

Definition at line 20 of file RestController.php.

◆ $model

$model
protected

Definition at line 19 of file RestController.php.

◆ $responseFormatter

$responseFormatter
protected

Definition at line 25 of file RestController.php.

◆ $restCache

$restCache
protected

Definition at line 21 of file RestController.php.

◆ $server

$server
protected

Definition at line 30 of file RestController.php.


The documentation for this class was generated from the following file: