19 declare(strict_types=1);
32 public function format(array $errors): string
38 $errors_to_display = [];
39 foreach ($errors as $error) {
40 $translation = $this->
lng->txt($error->getLanguageVariable());
41 if ($translation ===
'-' . $error->getLanguageVariable() .
'-') {
42 $translation = $error->getLanguageVariable();
45 if ($translation === $error->getLanguageVariable() || [] === $error->getPlaceHolderValues()) {
46 $errors_to_display[] = $translation;
48 $escaped_placeholder_values =
array_map(
static function (
string $value):
string {
50 }, $error->getPlaceHolderValues());
52 array_unshift($escaped_placeholder_values, $translation);
53 $errors_to_display[] = sprintf(...$escaped_placeholder_values);
58 'tpl.mail_new_submission_errors.html',
61 'components/ILIAS/Mail' 63 if (count($errors_to_display) === 1) {
64 $tpl->setCurrentBlock(
'single_error');
65 $tpl->setVariable(
'SINGLE_ERROR', current($errors_to_display));
67 $first_error = array_shift($errors_to_display);
68 foreach ($errors_to_display as $error) {
69 $tpl->setCurrentBlock(
'error_loop');
70 $tpl->setVariable(
'ERROR', $error);
71 $tpl->parseCurrentBlock();
74 $tpl->setCurrentBlock(
'multiple_errors');
75 $tpl->setVariable(
'FIRST_ERROR', $first_error);
77 $tpl->parseCurrentBlock();