Zend\Mvc\View\Http\InjectViewModelListener::injectViewModel PHP Method

injectViewModel() public method

Inspects the MVC result; if it's a view model, it then either (a) adds it as a child to the default, composed view model, or (b) replaces it if the result is marked as terminable.
public injectViewModel ( MvcEvent $e ) : void
$e Zend\Mvc\MvcEvent
return void
    public function injectViewModel(MvcEvent $e)
    {
        $result = $e->getResult();
        if (!$result instanceof ViewModel) {
            return;
        }
        $model = $e->getViewModel();
        if ($result->terminate()) {
            $e->setViewModel($result);
            return;
        }
        if ($e->getError() && $model instanceof ClearableModelInterface) {
            $model->clearChildren();
        }
        $model->addChild($result);
    }
InjectViewModelListener