public function apply(EndpointInvoker $endpointInvoker, $result)
    {
        if ($this->flightRecorder) {
            $this->flightRecorder->getStopWatch()->start('renderView');
        }

        if (is_array($result)) {
            $params = $result;
        } else {
            $params['vm'] = $result;
        }

        $params['user']  = $this->container->get(User::SERVICE_ID);
        $params['flash'] = $this->flashSession->getAllAndClear();

        $this->engine->init($endpointInvoker->getRoute()->getViewDirs(), $params);

        $rendered = $this->engine->render($endpointInvoker->getRoute()->getViewId());

        if ($this->flightRecorder) {
            $this->flightRecorder->getStopWatch()->stop('renderView');
        }

        return $rendered;
    }
public function apply(EndpointInvoker $endpointInvoker, $result)
    {
        if ($this->flightRecorder) {
            $this->flightRecorder->getStopWatch()->start('renderView');
        }

        if (is_array($result)) {
            $params = $result;
        } else {
            $params['vm'] = $result;
        }

        $params['user']  = $this->container->get(User::SERVICE_ID);
        $params['flash'] = $this->flashSession->getAllAndClear();

        $this->engine->init($endpointInvoker->getRoute()->getViewDirs(), $params);

        $rendered = $this->engine->render($endpointInvoker->getRoute()->getViewId());

        if ($this->flightRecorder) {
            $this->flightRecorder->getStopWatch()->stop('renderView');
        }

        return $rendered;
    }
@param EndpointInvoker $endpointInvoker
@param                 $result

@return mixed