Skip to content

Commit d4d146f

Browse files
Merge pull request #17289 from ozturkmtn/Extract-html-to-twig
Add libraries/classes/error::getDisplay() function twig file.
2 parents 5743de3 + 533a7ee commit d4d146f

2 files changed

Lines changed: 28 additions & 19 deletions

File tree

libraries/classes/Error.php

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -477,25 +477,17 @@ public function getDisplay(): string
477477
$context = 'danger';
478478
}
479479

480-
$retval = '<div class="alert alert-' . $context . '" role="alert">';
481-
if (! $this->isUserError()) {
482-
$retval .= '<strong>' . $this->getType() . '</strong>';
483-
$retval .= ' in ' . $this->getFile() . '#' . $this->getLine();
484-
$retval .= "<br>\n";
485-
}
486-
487-
$retval .= $this->getMessage();
488-
if (! $this->isUserError()) {
489-
$retval .= "<br>\n";
490-
$retval .= "<br>\n";
491-
$retval .= "<strong>Backtrace</strong><br>\n";
492-
$retval .= "<br>\n";
493-
$retval .= $this->getBacktraceDisplay();
494-
}
495-
496-
$retval .= '</div>';
497-
498-
return $retval;
480+
$template = new Template();
481+
482+
return $template->render('error/get_display',[
483+
'context' => $context,
484+
'isUserError' => $this->isUserError(),
485+
'type' => $this->getType(),
486+
'file' => $this->getFile(),
487+
'line' => $this->getLine(),
488+
'message' => $this->getMessage(),
489+
'backtraceDisplay' => $this->getBacktraceDisplay(),
490+
]);
499491
}
500492

501493
/**

templates/error/get_display.twig

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<div class="alert alert-{{ context }}" role="alert">
2+
3+
{% if isUserError == false %}
4+
<strong>{{ type }}</strong> in {{ file ~'#'~ line }} <br>
5+
{% endif %}
6+
7+
{{ message }}
8+
9+
{% if isUserError == false %}
10+
<br><br>
11+
<strong>Backtrace</strong><br>
12+
<br>
13+
{{ backtraceDisplay }}
14+
{% endif %}
15+
16+
17+
</div>

0 commit comments

Comments
 (0)