Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[DX] Easier template customizing with a query parameter #11327

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion 23 src/Symfony/Bundle/TwigBundle/Controller/ExceptionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,35 @@ public function showAction(Request $request, FlattenException $exception, DebugL

$code = $exception->getStatusCode();

$originalRequest = $request->attributes->get('original_request');

// allow the developer to see the real template with ?_real_template=1
$debug = $this->debug;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be easier to read in 1 line:

$debug = $this->debug && !$request->query->get('_real_template');

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this would break the code at line 61

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nvm I miseunderstood what you wrote

if ($debug && $originalRequest && $originalRequest->query->get('_real_template')) {
$debug = false;
}

// determine if we're able to show the link to view the true error template
$showErrorTemplateLink = false;
$errorTemplateParams = array();
if ($originalRequest && $originalRequest->isMethod('GET')) {
$showErrorTemplateLink = true;
$errorTemplateParams = array_merge(
$request->query->all(),
array('_real_template' => 1)
);
}

return new Response($this->twig->render(
$this->findTemplate($request, $_format, $code, $this->debug),
$this->findTemplate($request, $_format, $code, $debug),
array(
'status_code' => $code,
'status_text' => isset(Response::$statusTexts[$code]) ? Response::$statusTexts[$code] : '',
'exception' => $exception,
'logger' => $logger,
'currentContent' => $currentContent,
'showErrorTemplateLink' => $showErrorTemplateLink,
'errorTemplateParams' => $errorTemplateParams,
)
));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,16 @@
{% block body %}
{% include 'TwigBundle:Exception:exception.html.twig' %}
{% endblock %}

{% block header_right %}
{% if showErrorTemplateLink %}
<span class="sf-reset">
<a href="?{{ errorTemplateParams|url_encode }}"
title="Render the true error page that your end users will see"
onclick="alert('If you don\'t see an error page after the refresh, see: http://symfony.com/doc/current/cookbook/controller/error_pages.html');"
>
Render True Error Page
</a>
</span>
{% endif %}
{% endblock %}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
</span>
</span>
</button>

{% block header_right %}{% endblock %}
</div>
</form>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ protected function duplicateRequest(\Exception $exception, Request $request)
'_controller' => $this->controller,
'exception' => FlattenException::create($exception),
'logger' => $this->logger instanceof DebugLoggerInterface ? $this->logger : null,
'original_request' => $request,
// keep for BC -- as $format can be an argument of the controller callable
// see src/Symfony/Bundle/TwigBundle/Controller/ExceptionController.php
// @deprecated in 2.4, to be removed in 3.0
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.