com\setasign\SetaSite\Controller
ControllerDispatcher Class ControllerDispatcher
File: /SetaSite/src/Controller/ControllerDispatcher.php
Class hierarchy
- com\setasign\SetaFramework\Controller\ControllerDispatcher
Summary
Constants
EVENT_CATCH_ERROR
Will be called when a application catched an error.
Note: All applications have the same eventManager. Listeners need to check whether the event is in the right application.
Type: ErrorEvent
Cancelable: If the event is canceled, the error will not be catched!
extraParams:
'applicationName' => string
EVENT_INIT_CONTROLLER
Will be called when a controller will be initialized.
Note: All applications have the same eventManager. Listeners need to check whether the event is in the right application.
Type: ControllerDispatcherEvent
extraParams:
'applicationName' => string
'controllerName' => string
EVENT_POST_CALL
Will be called after all actions are called.
Note: All applications have the same eventManager. Listeners need to check whether the event is in the right application.
Type: ControllerDispatcherEvent
extraParams:
'applicationName' => string
'controllerName' => string
'actionName' => string
'params' => array
'result' => &mixed
EVENT_POST_RUN
Will be called after the application is finished. Also if there was an exception!
Listeners are able to change the response but not the View.
Note: All applications have the same eventManager. Listeners need to check whether the event is in the right application.
Type: ControllerDispatcherEvent
extraParams:
'applicationName' => string
EVENT_PRE_CALL
Will be called before an action will be called and before the controller is initialized.
Note: All applications have the same eventManager. Listeners need to check whether the event is in the right application.
Type: ControllerDispatcherEvent
extraParams:
'applicationName' => string
'controllerName' => &string
'actionName' => &string
'params' => &array
EVENT_PRE_RUN
Will be called when the run application is started.
Listeners are able to modify the routeData.
Note: All applications have the same eventManager. Listeners need to check whether the event is in the right application.
Type: ControllerDispatcherEvent
extraParams:
'applicationName' => string
Properties
$application
-
$eventManager
-
$initialized
-
All already initialized controllers
$lastController
-
$response
-
Methods
__construct()
-
\com\setasign\SetaFramework\EventManager\EventManager $eventManager
ControllerDispatcher constructor.
Parameters
- $application : \com\setasign\SetaFramework\Application\HttpApplicationInterface
- $eventManager : \com\setasign\SetaFramework\EventManager\EventManager
call()
-
string $actionName,
array $params = array ( )
Calls a action from a controller
If the controller isn't initialized so far initController will be called before.
Parameters
- $controllerName : string
- $actionName : string
- $params : array
Exceptions
Throws \com\setasign\SetaFramework\Controller\InitControllerException If the controller cannot be initialized.
Throws \Throwable
cleanActionName()
-
Parameters
- $actionName : string
cleanControllerName()
-
Parameters
- $controllerName : string
dispatch()
-
Parameters
- $routeData : array
Exceptions
Throws \Throwable If no errorHandler is defined, the error handler is invalid or the error handler throws an exception.
errorHandler()
-
Parameters
- $exception : \Throwable
- $controllerName : string
- $actionName : string
- $params : array
Exceptions
Throws \Throwable If no errorHandler is defined, the error handler is invalid or the error handler throws an exception.
getApplicationName()
-
getController()
-
array $params = array ( )
Returns the instance of the controller.
Parameters
- $controllerName : string
A controller name like Backend\Json\TestController
- $params : array
Exceptions
Throws \com\setasign\SetaFramework\Controller\InitControllerException if an exception occurs on building the controller.
Throws \InvalidArgumentException if the controller name is invalid.
getControllerName()
array $params = array ( )
Parameters
- $controllerName : string
- $params : array
getLastController()
-
Returns the last called controller
getResponse()
-
initController()
-
Initializes a controller
Parameters
- $controllerName : string
Full qualified classname
Exceptions
Throws \Throwable
setResponse()
-
This method can only be used in EVENT_POST_CALL and EVENT_POST_RUN
Parameters
- $response : \Psr\Http\Message\ResponseInterface
