Zend\Mvc\MiddlewareListener::marshalMiddlewareNotCallable PHP Method

marshalMiddlewareNotCallable() protected method

Marshal a middleware not callable exception event
protected marshalMiddlewareNotCallable ( string $type, string $middlewareName, MvcEvent $event, Application $application, Exception $exception = null ) : mixed
$type string
$middlewareName string
$event MvcEvent
$application Application
$exception Exception
return mixed
    protected function marshalMiddlewareNotCallable($type, $middlewareName, MvcEvent $event, Application $application, \Exception $exception = null)
    {
        $event->setName(MvcEvent::EVENT_DISPATCH_ERROR);
        $event->setError($type);
        $event->setController($middlewareName);
        $event->setControllerClass('Middleware not callable: ' . $middlewareName);
        if ($exception !== null) {
            $event->setParam('exception', $exception);
        }
        $events = $application->getEventManager();
        $results = $events->triggerEvent($event);
        $return = $results->last();
        if (!$return) {
            $return = $event->getResult();
        }
        return $return;
    }