Default dispatch listener

Pulls controllers from the service manager's "ControllerManager" service.

If the controller cannot be found a "404" result is set up. Otherwise it will continue to try to load the controller.

If the controller is not dispatchable it sets up a "404" result. In case of any other exceptions it trigger the "dispatch.error" event in an attempt to return a 500 status.

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.

package Default
inherited_from \Zend\EventManager\AbstractListenerAggregate

 Methods

Attach listeners to an event manager

attach(\Zend\EventManager\EventManagerInterface $events) : void

Parameters

$events

\Zend\EventManager\EventManagerInterface

Detach all previously attached listeners

detach(\Zend\EventManager\EventManagerInterface $events) 
Inherited
inherited_from \Zend\EventManager\ListenerAggregateInterface::detach()

Parameters

$events

Listen to the "dispatch" event

onDispatch(\Zend\Mvc\MvcEvent $e) : mixed

Parameters

$e

\Zend\Mvc\MvcEvent

Returns

mixed

reportMonitorEvent()

reportMonitorEvent(\Zend\Mvc\MvcEvent $e) 

Parameters

$e

\Zend\Mvc\MvcEvent

Complete the dispatch

complete(mixed $return, \Zend\Mvc\MvcEvent $event) : mixed

Parameters

$return

mixed

$event

\Zend\Mvc\MvcEvent

Returns

mixed

Marshal a bad controller exception event

marshalBadControllerEvent(string $controllerName, \Zend\Mvc\MvcEvent $event, \Zend\Mvc\Application $application, \Exception $exception) : mixed

Parameters

$controllerName

string

$event

\Zend\Mvc\MvcEvent

$application

\Zend\Mvc\Application

$exception

\Exception

Returns

mixed

Marshal a controller not found exception event

marshalControllerNotFoundEvent(string $type, string $controllerName, \Zend\Mvc\MvcEvent $event, \Zend\Mvc\Application $application, \Exception $exception = null) : mixed

Parameters

$type

string

$controllerName

string

$event

\Zend\Mvc\MvcEvent

$application

\Zend\Mvc\Application

$exception

\Exception

Returns

mixed

Marshal a controller not found exception event

marshallControllerNotFoundEvent(string $type, string $controllerName, \Zend\Mvc\MvcEvent $event, \Zend\Mvc\Application $application, \Exception $exception = null) : mixed
deprecated Use marshalControllerNotFoundEvent() instead

Parameters

$type

string

$controllerName

string

$event

\Zend\Mvc\MvcEvent

$application

\Zend\Mvc\Application

$exception

\Exception

Returns

mixed

 Properties

 

$listeners

$listeners : array<mixed,\Zend\Stdlib\CallbackHandler>

Default

array()