◆ __construct()
ilMailErrorFormatter::__construct |
( |
protected ilLanguage |
$lng | ) |
|
◆ format()
ilMailErrorFormatter::format |
( |
array |
$errors | ) |
|
Formats an error string based on the passed list of errors.
If the list contains > 1 elements, the 1st error will be used as a headline for the list of errors.
- Parameters
-
Definition at line 32 of file class.ilMailErrorFormatter.php.
References ILIAS\Repository\lng(), and ilLegacyFormElementsUtil\prepareFormOutput().
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();
The documentation for this class was generated from the following file: