jCoordinator
in package
the main class of the jelix core
this is the "chief orchestra" of the framework. Its goal is to load the configuration, to get the request parameters used to instancie the correspondant controllers and to run the right method.
Tags
Table of Contents
- $action : jSelectorAct
- the selector of the current action
- $actionName : string
- the current action name
- $moduleName : string
- the current module name
- $originalAction : jSelectorAct
- the original action when there is an internal redirection to an action different from the one corresponding to the request
- $plugins : array<string|int, mixed>
- plugin list
- $request : jRequest
- current request object
- $response : jResponse
- current response object
- $errorMessage : jLogErrorMessage
- the current error message
- __construct() : mixed
- errorHandler() : mixed
- Error handler using a response object to return the error.
- exceptionHandler() : mixed
- Exception handler using a response object to return the error Replace the default PHP Exception handler
- execOriginalAction() : bool
- says if the currently executed action is the original one
- getErrorMessage() : jLogErrorMessage
- getGenericErrorMessage() : string
- return the generic error message (errorMessage in the configuration).
- getPlugin() : jICoordPlugin
- gets a given coordinator plugin if registered
- handleError() : mixed
- Handle an error event. Called by error handler and exception handler.
- isPluginEnabled() : bool
- Says if the given coordinator plugin $name is enabled
- process() : mixed
- main method : launch the execution of the action.
- getController() : jController
- get the controller corresponding to the selector
- setRequest() : mixed
- initialize the given request and some properties of the coordinator
- _loadPlugins() : mixed
- load the plugins and their configuration file
Properties
$action
the selector of the current action
public
jSelectorAct
$action
=
ull
$actionName
the current action name
public
string
$actionName
$moduleName
the current module name
public
string
$moduleName
$originalAction
the original action when there is an internal redirection to an action different from the one corresponding to the request
public
jSelectorAct
$originalAction
=
ull
$plugins
plugin list
public
array<string|int, mixed>
$plugins
= array()
$request
current request object
public
jRequest
$request
=
ull
$response
current response object
public
jResponse
$response
=
ull
$errorMessage
the current error message
protected
jLogErrorMessage
$errorMessage
=
ull
Methods
__construct()
public
__construct([mixed $configFile = '' ][, bool $enableErrorHandler = true ]) : mixed
Parameters
- $configFile : mixed = ''
- $enableErrorHandler : bool = true
-
enable the error handler of jelix. keep it to true, unless you have something to debug and really have to use the default handler or an other handler
Return values
mixed —errorHandler()
Error handler using a response object to return the error.
public
errorHandler(int $errno, string $errmsg, string $filename, int $linenum) : mixed
Replace the default PHP error handler.
Parameters
- $errno : int
-
error code
- $errmsg : string
-
error message
- $filename : string
-
filename where the error appears
- $linenum : int
-
line number where the error appears
Tags
Return values
mixed —exceptionHandler()
Exception handler using a response object to return the error Replace the default PHP Exception handler
public
exceptionHandler(Exception $e) : mixed
Parameters
- $e : Exception
-
the exception object
Tags
Return values
mixed —execOriginalAction()
says if the currently executed action is the original one
public
execOriginalAction() : bool
Return values
bool —true if yes
getErrorMessage()
public
getErrorMessage() : jLogErrorMessage
Tags
Return values
jLogErrorMessage —the current error
getGenericErrorMessage()
return the generic error message (errorMessage in the configuration).
public
getGenericErrorMessage() : string
Replaced the %code% pattern in the message by the current error code
Return values
string —getPlugin()
gets a given coordinator plugin if registered
public
getPlugin(string $pluginName[, bool $required = true ]) : jICoordPlugin
Parameters
- $pluginName : string
-
the name of the plugin
- $required : bool = true
-
says if the plugin is required or not. If true, will generate an exception if the plugin is not registered.
Tags
Return values
jICoordPlugin —handleError()
Handle an error event. Called by error handler and exception handler.
public
handleError(string $type, int $code, string $message, string $file, int $line, array<string|int, mixed> $trace) : mixed
Parameters
- $type : string
-
error type : 'error', 'warning', 'notice'
- $code : int
-
error code
- $message : string
-
error message
- $file : string
-
the file name where the error appear
- $line : int
-
the line number where the error appear
- $trace : array<string|int, mixed>
-
the stack trace
Tags
Return values
mixed —isPluginEnabled()
Says if the given coordinator plugin $name is enabled
public
isPluginEnabled(string $pluginName) : bool
Parameters
- $pluginName : string
Return values
bool —true : plugin is ok
process()
main method : launch the execution of the action.
public
process([jRequest $request = null ]) : mixed
This method should be called in a entry point.
Parameters
- $request : jRequest = null
-
the request object. It is required if a descendant of jCoordinator did not called setRequest before
Tags
Return values
mixed —getController()
get the controller corresponding to the selector
protected
getController(jSelectorAct $selector) : jController
Parameters
- $selector : jSelectorAct
Tags
Return values
jController —the controller corresponding to the selector
setRequest()
initialize the given request and some properties of the coordinator
protected
setRequest(jRequest $request) : mixed
It extracts information for the request to set the module name and the action name. It doesn't verify if the corresponding controller does exist or not. It enables also the error handler of Jelix, if needed. Does not call this method directly in entry points. Prefer to call process() instead (that will call setRequest). setRequest is mostly used for tests or specific contexts.
Parameters
- $request : jRequest
-
the request object
Tags
Return values
mixed —_loadPlugins()
load the plugins and their configuration file
private
_loadPlugins() : mixed