Ubiquity 2.5.2
php rapid development framework
Loading...
Searching...
No Matches
Controller Class Reference

Base class for controllers. More...

+ Inheritance diagram for Controller:

Public Member Functions

 index ()
 Default action.
 
 __construct ()
 Constructor initialize $view variable.
 
 initialize ()
 Method called before each action Can be override in derived class.
 
 finalize ()
 Method called after each action Can be override in derived class.
 
 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
 
 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.
 
 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.
 

Protected Attributes

View $view
 

Detailed Description

Base class for controllers.

Ubiquity\controllers$Controller This class is part of Ubiquity

Author
jcheron myadd.nosp@m.ress.nosp@m.mail@.nosp@m.gmai.nosp@m.l.com
Version
1.0.9

Definition at line 20 of file Controller.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( )

Constructor initialize $view variable.

Reimplemented in CRUDController, RestBaseController, and SimpleViewController.

Definition at line 38 of file Controller.php.

Member Function Documentation

◆ finalize()

finalize ( )

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

Reimplemented in AuthController, ControllerBase, and RestBaseController.

Definition at line 53 of file Controller.php.

◆ forward()

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.

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

Exception

Definition at line 133 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 If there is an activeTheme @activeTheme/ControllerName/actionName.html

Returns
string the default view name

Definition at line 95 of file Controller.php.

◆ getView()

getView ( )

Returns the associated view instance.

Returns
\Ubiquity\views\View

Definition at line 176 of file Controller.php.

◆ index()

index ( )
abstract

Default action.

Reimplemented in AuthController, CRUDController, RestBaseController, and SeoController.

◆ initialize()

initialize ( )

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

Reimplemented in AuthController, AuthControllerConfig, ControllerBase, MultiResourceCRUDController, RestBaseController, and RestResourceController.

Definition at line 46 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

Reimplemented in AuthController, and RestBaseController.

Definition at line 109 of file Controller.php.

◆ loadDefaultView()

loadDefaultView (   $pData = null,
bool  $asString = false 
)

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

(@activeTheme/controllerName/actionName if themes are activated)

Parameters
mixed$pDataVariable or associative array to pass to the view If a variable is passed, it will have the name $data 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)
Returns
string null or the view content if $asString parameter is true
Exceptions

Exception

Definition at line 85 of file Controller.php.

◆ loadView()

loadView ( string  $viewName,
  $pData = null,
bool  $asString = false 
)

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

Parameters
string$viewNameThe name of the view to load
mixed$pDataVariable or associative array to pass to the view If a variable is passed, it will have the name $data 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)
Returns
string null or the view content if $asString parameter is true
Exceptions

Exception

Reimplemented in SimpleViewAsyncController, and SimpleViewController.

Definition at line 67 of file Controller.php.

◆ onInvalidControl()

onInvalidControl ( )

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

Reimplemented in RestBaseController.

Definition at line 117 of file Controller.php.

◆ redirectToRoute()

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

Redirect to a route by its name.

Parameters
string$routeNameThe route name
array$parametersThe parameters to pass to the route action
boolean$initializeCall the initialize method if true
boolean$finalizeCall the finalize method if true
Exceptions
RouterException

Definition at line 152 of file Controller.php.

Field Documentation

◆ $view

View $view
protected

Definition at line 27 of file Controller.php.


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