Collect the date for the Toolbar item.

@param Request    $request
@param Response   $response
@param \Exception $exception
434723
public function collect(Request $request, Response $response, \Exception $exception = null)
    {
        $this->data = [
            'version'       => Bolt\Version::VERSION,
            'payoff'        => 'Sophisticated, lightweight & simple CMS',
            'dashboardlink' => sprintf('<a href="%s">%s</a>', $this->app['url_generator']->generate('dashboard'), 'Dashboard'),
            'branding'      => null,
            'editlink'      => null,
            'edittitle'     => null,
        ];

        if ($this->app['config']->get('general/branding/provided_by/0')) {
            $this->data['branding'] = sprintf(
                '%s %s',
                Trans::__('general.phrase.provided-by-colon'),
                $this->app['config']->get('general/branding/provided_link')
            );
        }

        if (!empty($this->app['editlink'])) {
            $this->data['editlink'] = $this->app['editlink'];
            $this->data['edittitle'] = $this->app['edittitle'];
        }
    }
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);
    }
226442
protected function duplicateRequest(\Exception $exception, Request $request)
    {
        $attributes = [
            'exception' => $exception = FlattenException::create($exception),
            '_controller' => $this->controller ?: function () use ($exception) {
                $handler = new ExceptionHandler($this->debug, $this->charset, $this->fileLinkFormat);

                return new Response($handler->getHtml($exception), $exception->getStatusCode(), $exception->getHeaders());
            },
            'logger' => $this->logger instanceof DebugLoggerInterface ? $this->logger : null,
        ];
        $request = $request->duplicate(null, null, $attributes);
        $request->setMethod('GET');

        return $request;
    }
155545
public function render($request, Exception $exception)
    {
        $this->transformException($exception);

        if ($exception instanceof ApiException) {
            return $this->renderApiError($exception);
        }

        return parent::render($request, $exception);
    }
716594
public function collect(Request $request, Response $response, \Exception $exception = null)
    {
        $statData = $this->getStatsdDataFactory()->gauge($this->getStatsDataKey(), $this->getMemoryUsage());
        $this->addStatsData($statData);

        return true;
    }
45788
public function onAuthenticationFailure(Request $request, AuthenticationException $exception)
    {
        $data = array(
            'message' => strtr($exception->getMessageKey(), $exception->getMessageData())
        );
        $def_response = new JsonResponse($data, 403);

        $event = new CASAuthenticationFailureEvent($request,$exception, $def_response);
        $this->eventDispatcher->dispatch(CASAuthenticationFailureEvent::POST_MESSAGE, $event);

        return $event->getResponse();
    }
667582
public function sendEmail(Exception $exception)
    {
        try {
            $e = FlattenException::create($exception);
            $handler = new SymfonyExceptionHandler();
            $html = $handler->getHtml($e);

            Mail::send(new ExceptionOccured($html));
        } catch (Exception $exception) {
            Log::error($exception);
        }
    }
987686
private function handleHttpException(HttpException $exception, Request $request) : Response
    {
        $response = new Response();

        $response->setContent($exception);
        $response->setStatusCode($exception->getStatusCode());
        $response->setHeaders($exception->getHeaders());
        $response->setHeader('Content-Type', 'text/plain');

        $event = new ExceptionCaughtEvent($exception, $request, $response);
        $this->eventDispatcher->dispatch(ExceptionCaughtEvent::class, $event);

        return $response;
    }
1119314
public function collect(Request $request, Response $response, \Exception $exception = null)
    {
        $parameters = array();
        $services = array();

        $this->loadContainerBuilder();

        if ($this->containerBuilder !== false) {
            foreach ($this->containerBuilder->getParameterBag()->all() as $key => $value) {
                $service = substr($key, 0, strpos($key, '.'));
                if (!isset($parameters[$service])) {
                    $parameters[$service] = array();
                }
                $parameters[$service][$key] = $value;
            }

            $serviceIds = $this->containerBuilder->getServiceIds();
            foreach ($serviceIds as $serviceId) {
                $definition = $this->resolveServiceDefinition($serviceId);

                if ($definition instanceof Definition && $definition->isPublic()) {
                    $services[$serviceId] = array('class' => $definition->getClass());
                } elseif ($definition instanceof Alias) {
                    $services[$serviceId] = array('alias' => $definition);
                } else {
                    continue;    // We don't want private services
                }
            }

            ksort($services);
            ksort($parameters);
        }
        $this->data['parameters'] = $parameters;
        $this->data['services'] = $services;
    }
954802
private function handleException(\Exception $exception, Request $request, $type)
    {
        $event = new GetResponseForExceptionEvent($this, $request, $type, $exception);
        $this->application->getEventDispatcher()->dispatch(KernelEvents::EXCEPTION, $event);

        return $event->getResponse();
    }
274000
public function render($request, Exception $exception)
    {
        if ($exception instanceof TokenExpiredException) {
            return response()->json(['token_expired'], $exception->getCode());
        } else if ($exception instanceof TokenInvalidException) {
            return response()->json(['token_invalid'], $exception->getCode());
        }
        return parent::render($request, $exception);
    }
278026
protected function createView(\Exception $exception, $code, array $templateData, Request $request, $showException)
    {
        $view = new View($exception, $code, $exception instanceof HttpExceptionInterface ? $exception->getHeaders() : []);
        $view->setTemplateVar('raw_exception');
        $view->setTemplateData($templateData);

        return $view;
    }
810952
protected function getResponse(Request $request, Exception $exception, Exception $transformed)
    {
        $id = $this->container->make(ExceptionIdentifier::class)->identify($exception);

        $flattened = FlattenException::create($transformed);
        $code = $flattened->getStatusCode();
        $headers = $flattened->getHeaders();

        return $this->getDisplayer($request, $exception, $transformed, $code)->display($transformed, $id, $code, $headers);
    }
875569
public function collect(Request $request, Response $response, \Exception $exception = null)
    {
        if (false === $this->enabled) {
            return;
        }

        $profile = new Profile(substr(hash('sha256', uniqid(mt_rand(), true)), 0, 6));
        $profile->setTime(time());
        $profile->setUrl($request->getUri());
        $profile->setMethod($request->getMethod());
        $profile->setStatusCode($response->getStatusCode());
        try {
            $profile->setIp($request->getClientIp());
        } catch (ConflictingHeadersException $e) {
            $profile->setIp('Unknown');
        }

        if ($prevToken = $response->headers->get('X-Debug-Token')) {
            $response->headers->set('X-Previous-Debug-Token', $prevToken);
        }

        $response->headers->set('X-Debug-Token', $profile->getToken());

        foreach ($this->collectors as $collector) {
            $collector->collect($request, $response, $exception);

            // we need to clone for sub-requests
            $profile->addCollector(clone $collector);
        }

        return $profile;
    }
1061274
protected function errorResponse(Request $request, \Exception $exception): JsonResponse
    {
        if ($exception instanceof EntryNotFoundException || $exception instanceof SectionNotFoundException) {
            $statusCode = JsonResponse::HTTP_NOT_FOUND;
        } else {
            $statusCode = JsonResponse::HTTP_BAD_REQUEST;
        }
        return new JsonResponse([
            'error' => $exception->getMessage()
        ], $statusCode, $this->getDefaultResponseHeaders($request));
    }
530801
protected function injectToolbar(Response $response, Request $request)
    {
        $content = $response->getContent();
        $pos = strripos($content, '</body>');

        if (false !== $pos) {
            $toolbar = "\n".str_replace(
                    "\n",
                    '',
                    $this->twig->render(
                        '@KunstmaanAdmin/Toolbar/toolbar.html.twig',
                        ['collectors' => $this->dataCollector->getDataCollectors()]
                    )
                )."\n";
            $content = substr($content, 0, $pos).$toolbar.substr($content, $pos);
            $response->setContent($content);
        }
    }
828392
public function showAction(Request $request, $exception, DebugLoggerInterface $logger = null)
    {
        $currentContent = $this->getAndCleanOutputBuffering($request->headers->get('X-Php-Ob-Level', -1));
        $code = $this->getStatusCode($exception);
        $templateData = $this->getTemplateData($currentContent, $code, $exception, $logger);

        $view = $this->createView($exception, $code, $templateData, $request, $this->showException);
        $response = $this->viewHandler->handle($view);

        return $response;
    }