PHP Class Zend\Mvc\DispatchListener

Pulls controllers from the service manager's "ControllerLoader" service. If the controller cannot be found, or is not dispatchable, sets up a "404" result. If the controller subscribes to InjectApplicationEventInterface, it injects the current MvcEvent into the controller. It then calls the controller's "dispatch" method, passing it the request and response. If an exception occurs, it triggers the "dispatch.error" event, in an attempt to return a 500 status. The return value of dispatching the controller is placed into the result property of the MvcEvent, and returned.
Inheritance: implements Zend\EventManager\ListenerAggregateInterface
Show file Open project: zendframework/zend-mvc

Public Methods

Method Description
__construct ( ControllerManager $controllerManager )
attach ( Zend\EventManager\EventManagerInterface $events, integer $priority = 1 ) : void Attach listeners to an event manager
onDispatch ( MvcEvent $e ) : mixed Listen to the "dispatch" event
reportMonitorEvent ( MvcEvent $e )

Protected Methods

Method Description
complete ( mixed $return, MvcEvent $event ) : mixed Complete the dispatch
marshalBadControllerEvent ( string $controllerName, MvcEvent $event, Application $application, Throwable | Exception $exception ) : mixed Marshal a bad controller exception event
marshalControllerNotFoundEvent ( string $type, string $controllerName, MvcEvent $event, Application $application, Throwable | Exception $exception = null ) : mixed Marshal a controller not found exception event

Method Details

__construct() public method

public __construct ( ControllerManager $controllerManager )
$controllerManager Zend\Mvc\Controller\ControllerManager

attach() public method

Attach listeners to an event manager
public attach ( Zend\EventManager\EventManagerInterface $events, integer $priority = 1 ) : void
$events Zend\EventManager\EventManagerInterface
$priority integer
return void

complete() protected method

Complete the dispatch
protected complete ( mixed $return, MvcEvent $event ) : mixed
$return mixed
$event MvcEvent
return mixed

marshalBadControllerEvent() protected method

Marshal a bad controller exception event
protected marshalBadControllerEvent ( string $controllerName, MvcEvent $event, Application $application, Throwable | Exception $exception ) : mixed
$controllerName string
$event MvcEvent
$application Application
$exception Throwable | Exception
return mixed

marshalControllerNotFoundEvent() protected method

Marshal a controller not found exception event
protected marshalControllerNotFoundEvent ( string $type, string $controllerName, MvcEvent $event, Application $application, Throwable | Exception $exception = null ) : mixed
$type string
$controllerName string
$event MvcEvent
$application Application
$exception Throwable | Exception
return mixed

onDispatch() public method

Listen to the "dispatch" event
public onDispatch ( MvcEvent $e ) : mixed
$e MvcEvent
return mixed

reportMonitorEvent() public method

public reportMonitorEvent ( MvcEvent $e )
$e MvcEvent