Render the processor result.

The result is rendered triggering a "render" event on a cloned MvcEvent,
simulating the usual MVC render flow.

@todo investigate if simulation works in all cases
@param ProcessEvent $e
179472
public function postProcess(ProcessEvent $e)
    {
        $appEvent       = clone $e->getWorker()->getEvent();
        $appEvent->setTarget($appEvent->getApplication());

        $appEvents      = $appEvent->getApplication()->getEventManager();

        $appResponse    = clone $appEvent->getResponse();
        $appEvent->setResponse($appResponse);
        $appEvent->setResult($e->getResult());

        $appEvents->trigger(MvcEvent::EVENT_RENDER, $appEvent);

        $e->setResult($appEvent->getResponse()->getContent());

        if (Console::isConsole() && is_string($e->getResult())) {
            echo $e->getResult();
        }
    }
880155
public function renderPlainText(\Throwable $e, Inspector $inspector, RunInterface $run) : int
    {
        if ($this->isDisplayError()) {
            $response = new PlainTextHandler();
            $response->setRun($run);
            $response->setInspector($inspector);
            $response->addTraceToOutput(true);
            $response->setException($e);
            return $response->handle();
        }

        echo "There was an error";
        return Handler::DONE;
    }
397250
protected function renderHttpResponse($e)
    {
        $error = '';
        $errorArray = [];

        if ($this->container['env'] != 'prod') {
            $error = $e;
            if (!is_array($error)) {
                $trace = debug_backtrace();
                $errorArray['message'] = $e;
                $errorArray['file'] = $trace[0]['file'];
                $errorArray['line'] = $trace[0]['line'];
                ob_start();
                debug_print_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
                $e['trace'] = ob_get_clean();
                $error = $errorArray;
            }

            $this->container['eventDispatcher']->dispatch(AppEvent::EXCEPTION, new ExceptionEvent($error, $this->container));
        }

        if ($this->container['env'] == 'prod') {
            $this->container['eventDispatcher']->dispatch(AppEvent::EXCEPTION, new ExceptionEvent($e, $this->container));
        }
    }
657187
public function render(Request $request, Exception $e)
    {
        $e = $this->prepareException($e);

        if ($e instanceof HttpResponseException) {
            return $e->getResponse();
        } else if ($e instanceof AuthenticationException) {
            return $this->unauthenticated($request, $e);
        } else if ($e instanceof ValidationException) {
            return $this->convertValidationExceptionToResponse($e, $request);
        }

        return $this->prepareResponse($request, $e);
    }
638829
public function renderException(\Exception $e, OutputInterface $output)
    {
        parent::renderException($e, $output);

        if (is_callable($this->exceptionHandler)) {
            try {
                if (method_exists($this->exceptionHandler, '__invoke')) {
                    $this->exceptionHandler->__invoke($e);
                } else {
                    call_user_func($this->exceptionHandler, $e);
                }
            } catch (\Exception $e) {
            }
        }
    }
134386
public function render($request, $e)
	{
		if ($e instanceof \Error)
		{
			$e = new \Exception('Exception occured: ' . $e->getMessage() . "\nOriginal stack trace: " . 
				$e->getTraceAsString(), $e->getCode());
		}
		
		// If the request wants JSON (AJAX doesn't always want JSON)
		if ($request->wantsJson())
		{
			// Define the response
			$response = [
				'errors' => 'Sorry, something went wrong.'
			];

			// If the app is in debug mode
			if (config('app.debug'))
			{
				// Add the exception class name, message and stack trace to response
				$response['exception'] = get_class($e); // Reflection might be better here
				$response['message'] = $e->getMessage();
				$response['trace'] = $e->getTrace();
			}

			// Default response of 400
			$status = 400;

			// If this exception is an instance of HttpException
			if ($this->isHttpException($e))
			{
				// Grab the HTTP status code from the Exception
				$status = $e->getStatusCode();
			}

			// Return a JSON response with the response array and status code
			return response()->json($response, $status);
		}
		
		if ($this->isHttpException($e))
		{
			return $this->renderHttpException($e);
		}
		else
		{
			return (new SymfonyDisplayer(config('app.debug')))->createResponse($e);
		}
	}
641089
public function onRoute(MvcEvent $e)
    {
        if (!$e->getRequest() instanceof HttpRequest || !$e->getResponse() instanceof HttpResponse) {
            return null;
        }

        /** @var HttpResponse $response */
        $response = $e->getResponse();

        $data = $this->getCacheService()->load($e);

        if ($data !== null) {
            $this->loadedFromCache = true;

            if ($this->getOptions()->getCacheResponse() === true) {
                $response = unserialize($data);
            } else {
                $response = $e->getResponse();
                $response->setContent($data);
            }

            $this->addDebugResponseHeader($response, 'Hit');

            return $response;
        }

        $this->addDebugResponseHeader($response, 'Miss');
    }
887840
public function render($request, Exception $e)
    {
        if (method_exists($e, 'render') && $response = $e->render($request)) {
            return Router::toResponse($request, $response);
        } elseif ($e instanceof Responsable) {
            return $e->toResponse($request);
        }

        $e = $this->prepareException($e);

        if ($e instanceof HttpResponseException) {
            return $e->getResponse();
        } elseif ($e instanceof AuthenticationException) {
            return $this->unauthenticated($request, $e);
        } elseif ($e instanceof ValidationException) {
            return $this->convertValidationExceptionToResponse($e, $request);
        }

        return $request->expectsJson()
                        ? $this->prepareJsonResponse($request, $e)
                        : $this->prepareResponse($request, $e);
    }
1273652
public function render($request, Exception $e)
    {
        if (app()->environment() == 'testing') {
            throw $e;
        }
        if ($e instanceof NotFoundHttpException) {
            if ($request->method() == "GET") {
                return array_key_exists('extension', pathinfo(array_key_exists('path', $parsed = parse_url($request->url()))
                        ? $parsed['path']
                        : null))
                    ? errors(['Not Found'], 404)
                    : html()->generate(); 
            } 
            return errors(['Not Found'], 404);
        }
        if ($e instanceof MethodNotAllowedHttpException) {
            if ($request->method() == "GET") {
                return html()->generate();
            }  
            return parent::render($request, $e);          
        }
        if (app()->environment() == 'local') {
            return errors([$e->getMessage(), $e->getFile() . ': line ' . $e->getLine()], 500);
        }
        return errors([$e->getMessage()], 500);
    }
742349
@Override
    public void render(ElementTemplate eleTemplate, Object data, XWPFTemplate template) {
        RunTemplate runTemplate = (RunTemplate) eleTemplate;
        // validate
        if (!validate(data)) {
            clearPlaceholder(runTemplate.getRun());
            return;
        }

        // do render
        try {
            doRender(runTemplate, data, template);
        } catch (Exception e) {
            doRenderException(runTemplate, data, e);
        }

    }
1310703
public function onBootstrap(MvcEvent $e)
    {
        // we attach with wildcard events name
        $events = $e->getApplication()->getEventManager();
        $events->attach(
            MvcEvent::EVENT_RENDER,
            new InjectSubNavigationListener(),
            10
        );
    }
15142
private function doExecute(
        InputInterface $input,
        OutputInterface $output,
        QueueInterface $queue,
        ProcessesManager $processManager
    ) {
        $processes = null;

        if ($this->isVerbose($output)) {
            $progressBar = new VerboseRenderer($queue->count(), $this->hasErrorSummary($input), $output);
        } else {
            $progressBar = new ProgressBarRenderer($queue->count(), $this->hasErrorSummary($input), $output, new ProgressBar($output));
        }

        $progressBar->renderHeader($queue);

        while ($processManager->assertNProcessRunning($queue, $processes)) {
            $progressBar->renderBody($queue, $processes);
        }

        /*
         * @var Processes $processes
         */
        $processes->cleanUP(); //it is not getting called with -p1 after the last process otherwise
        $processes->wait(function () use ($progressBar, $queue, $processes) {
            $progressBar->renderBody($queue, $processes);
        });
        $progressBar->renderFooter($queue, $processes);

        return $processes;
    }
649844
public function render($request, Exception $e)
	{
		if ($this->isHttpException($e))
		{
			return $this->renderHttpException($e);
		}
		else
		{
			return parent::render($request, $e);
		}
	}
16894
public function render(Exception $e)
    {
        if ($e instanceof HttpResponseException) {
            /* error occurs */
            switch ($e->getCode()) {
                case HttpResponseException::ERR_NOTFOUND_CONTROLLER:
                case HttpResponseException::ERR_NOTFOUND_ACTION:
                case HttpResponseException::ERR_NOTFOUND_VIEW:
                    response()->setStatusCode(404);
                    echo htmlspecialchars($e->getMessage());
                    break;
                default :
                    echo 0, ':', htmlspecialchars($e->getMessage());
                    break;
            }
        } else {
            $this->convertExceptionToResponse($e);
        }
    }
1233557
public function injectResponse(ViewEvent $e)
    {
        $renderer = $e->getRenderer();

        if ($renderer !== $this->renderer) {
            return;
        }

        $result   = $e->getResult();

        /** @var HttpResponse $response */
        $response = $e->getResponse();
        $response->setContent($result);
        $headers = $response->getHeaders();
        //$headers->addHeaderLine('Content-length', strlen($result));
        $headers->addHeaderLine('content-type', 'text/xml');
    }
582422
public function process()
	{
		$view = $this->getView();

		if( $view->param( 'cs-order', null ) === null ) {
			return;
		}

		try
		{
			$controller = Controller_Frontend_Factory::createController( $this->_getContext(), 'basket' );
			$controller->get()->check( MShop_Order_Item_Base_Abstract::PARTS_ALL );

			parent::process();
		}
		catch( Exception $e )
		{
			$view->standardStepActive = 'summary';
			throw $e;
		}
	}
427598
public function selectRenderer(ViewEvent $e)
    {
        $model = $e->getModel();

        if (!($model instanceof WorkflowDescriptorApiModel || $model instanceof HalEntity)) {
            return null;
        }

        $this->renderer->setViewEvent($e);

        return $this->renderer;
    }