com\setasign\SetaFramework\Controller
ControllerDispatcher Class ControllerDispatcher
File: /SetaFramework/src/Controller/ControllerDispatcher.php
Class hierarchy
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
$lastController
$response
Methods
__construct()
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 InitControllerException If the controller cannot be initialized.
Throws \Throwable
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.
getController()
array $params = array ( )
Returns the instance of the controller.
Parameters
- $controllerName : string
A controller name like Backend\Json\TestController
- $params : array
Exceptions
Throws InitControllerException if an exception occurs on building the controller.
Throws \InvalidArgumentException if the controller name is invalid.
getControllerName()
array $params = array ( )
Get the full classname or an alias of the controller belongs to $controllerName
Parameters
- $controllerName : string
- $params : array
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
