Ubiquity  2.0.3
php rapid development framework
Controller Class Reference

Base class for controllers. More...

+ Inheritance diagram for Controller:

Public Member Functions

 index ()
 Default action. More...
 
 __construct ()
 Constructor initialize $view variable. 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...
 
 loadDefaultView ($pData=NULL, $asString=false)
 Loads the default view (controllerName/actionName) possibly passing the variables $pdata. More...
 
 getDefaultViewName ()
 Returns the default view name for this controller/action i.e ControllerName/actionName.html for the action actionName in ControllerName. More...
 
 isValid ($action)
 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...
 
 getView ()
 

Protected Attributes

 $view
 

Detailed Description

Base class for controllers.

Author
jcheron
Version
1.0.3

Definition at line 18 of file Controller.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( )

Constructor initialize $view variable.

Definition at line 35 of file Controller.php.

Member Function Documentation

◆ finalize()

finalize ( )

Method called after each action Can be override in derived class.

Definition at line 50 of file Controller.php.

◆ forward()

forward (   $controller,
  $action = "index",
  $params = array(),
  $initialize = false,
  $finalize = false 
)

Loads the controller $controller and calls its $action method by passing the parameters $params.

Parameters
string$controllerThe Controller
string$actionThe action to call
mixed$paramsParameters passed to the $action method
boolean$initializeIf true, the controller's initialize method is called before $action
boolean$finalizeIf true, the controller's finalize method is called after $action
Exceptions

Definition at line 128 of file Controller.php.

◆ getDefaultViewName()

getDefaultViewName ( )

Returns the default view name for this controller/action i.e ControllerName/actionName.html for the action actionName in ControllerName.

Returns
string the default view name

Definition at line 90 of file Controller.php.

◆ getView()

getView ( )
Returns

Definition at line 165 of file Controller.php.

◆ index()

index ( )
abstract

Default action.

◆ initialize()

initialize ( )

Method called before each action Can be override in derived class.

Definition at line 43 of file Controller.php.

◆ isValid()

isValid (   $action)

Returns True if access to the controller is allowed To be override in sub classes.

Parameters
string$action
Returns
boolean

Definition at line 101 of file Controller.php.

◆ loadDefaultView()

loadDefaultView (   $pData = NULL,
  $asString = false 
)

Loads the default view (controllerName/actionName) possibly passing the variables $pdata.

Parameters
mixed$pDataVariable or associative array to pass to the view
If a variable is passed, it will have the name $ data </ b> in the view,
If an associative array is passed, the view retrieves variables from the table's key names
boolean$asString If true, the view is not displayed but returned as a string (usable in a variable)
Exceptions

Definition at line 82 of file Controller.php.

◆ loadView()

loadView (   $viewName,
  $pData = NULL,
  $asString = false 
)

Loads the view $viewName possibly passing the variables $pdata.

Parameters
string$viewNameview name to load
mixed$pDataVariable or associative array to pass to the view
If a variable is passed, it will have the name $ data </ b> in the view,
If an associative array is passed, the view retrieves variables from the table's key names
boolean$asString If true, the view is not displayed but returned as a string (usable in a variable)
Exceptions

Definition at line 66 of file Controller.php.

◆ onInvalidControl()

onInvalidControl ( )

Called if isValid () returns false
To be override in sub classes.

Definition at line 109 of file Controller.php.

◆ redirectToRoute()

redirectToRoute (   $routeName,
  $parameters = [],
  $initialize = false,
  $finalize = false 
)

Redirect to a route by its name.

Parameters
string$routeName
array$parameters
boolean$initialize
boolean$finalize
Exceptions
RouterException

Definition at line 147 of file Controller.php.

Field Documentation

◆ $view

$view
protected

Definition at line 24 of file Controller.php.


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