Ubiquity  2.0.2
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
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 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
Automatically invokes the isValid () method to check if access is allowed.

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 52 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 96 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 45 of file Controller.php.

◆ isValid()

isValid ( )

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

Returns
boolean

Definition at line 75 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$asStringIf true, the view is not displayed but returned as a string (usable in a variable)
Exceptions

Definition at line 64 of file Controller.php.

◆ onInvalidControl()

onInvalidControl ( )

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

Definition at line 83 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 114 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: