com\setasign\Konquadrat\Controller

ControllerDispatcher Class ControllerDispatcher

File: /Konquadrat/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

$initialized

All already initialized controllers

$response

protected ?\Psr\Http\Message\ResponseInterface \com\setasign\SetaFramework\Controller\ControllerDispatcher::$response

Methods

call()

protected \com\setasign\SetaFramework\Controller\ControllerDispatcher::call (
string $controllerName,
string $actionName,
array $params = array ( )
): ?mixed

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()

protected \com\setasign\SetaFramework\Controller\ControllerDispatcher::errorHandler (
\Throwable $exception,
string $controllerName,
string $actionName,
array $params
): ?mixed
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()

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()

protected ControllerDispatcher::getControllerName (
string $controllerName,
array $params = array ( )
): string

Get the full classname or an alias of the controller belongs to $controllerName

Parameters
$controllerName: string
 
$params: array
 

getResponse()

public \com\setasign\SetaFramework\Controller\ControllerDispatcher::getResponse (
void
): ?\Psr\Http\Message\ResponseInterface

initController()

Initializes a controller

Parameters
$controllerName: string

Full qualified classname

Exceptions

Throws \Throwable

setResponse()

public \com\setasign\SetaFramework\Controller\ControllerDispatcher::setResponse (
\Psr\Http\Message\ResponseInterface $response
): void

This method can only be used in EVENT_POST_CALL and EVENT_POST_RUN

Parameters
$response: \Psr\Http\Message\ResponseInterface