Skip to content
Snippets Groups Projects
Commit 2f70c283 authored by Bernd Oliver Suenderhauf's avatar Bernd Oliver Suenderhauf
Browse files

Issue #3062140 by Pancho: Use item_list render arrays with #prefix/#suffix in status messages

parent 9ea8029a
No related branches found
No related tags found
No related merge requests found
......@@ -513,10 +513,14 @@ class FillPdfFormForm extends ContentEntityForm {
$this->messenger()->addStatus($this->t('Your previous field mappings have been transferred to the new PDF template you uploaded.'));
}
if (count($non_matching_fields)) {
$this->messenger()->addWarning($this->t("These keys couldn't be found in the new PDF:"));
foreach (array_keys($non_matching_fields) as $pdf_key) {
$this->messenger()->addWarning($pdf_key);
}
$message = [
'#prefix' => $this->t("These keys couldn't be found in the new PDF:"),
[
'#theme' => 'item_list',
'#items' => array_keys($non_matching_fields),
],
];
$this->messenger()->addWarning(\Drupal::service('renderer')->render($message));
}
$this->messenger()->addStatus($this->t('You might also want to update the <em>Filename pattern</em> field; this has not been changed.'));
......
......@@ -155,10 +155,10 @@ class FillPdfSettingsForm extends ConfigFormBase {
$template_scheme = $config->get('template_scheme');
// Set an error if the previously configured scheme doesn't exist anymore.
if ($template_scheme && !array_key_exists($template_scheme, $template_scheme_options)) {
$error_message = $this->t('Your previously used file storage %previous_scheme is no longer available on this Drupal site, see the %system_settings. Please reset your default to an existing file storage.', [
$this->messenger()->addError($this->t('Your previously used file storage %previous_scheme is no longer available on this Drupal site, see the %system_settings. Please reset your default to an existing file storage.', [
'%previous_scheme' => $template_scheme . '://',
'%system_settings' => Link::createFromRoute($this->t('File system settings'), 'system.file_system_settings')->toString(),
]);
]));
// @todo: It would be helpful if we could use EntityQuery instead, see
// https://www.drupal.org/project/fillpdf/issues/3043508.
......@@ -174,16 +174,16 @@ class FillPdfSettingsForm extends ConfigFormBase {
$link = Link::fromTextAndUrl($admin_title ?: "FillPDF form {$fillpdf_form->id()}", $fillpdf_form->toUrl());
$items[$form_id] = new FormattableMarkup("@fillpdf_form: {$file_uri}", ['@fillpdf_form' => $link->toString()]);
}
$list = [
'#theme' => 'item_list',
'#items' => $items,
$error_message = [
'#prefix' => $this->t('Nevertheless, the following FillPDF forms will not work until their respective PDF templates have been moved to an existing file scheme:'),
[
'#theme' => 'item_list',
'#items' => $items,
],
];
$error_message .= '<br />' . $this->t('Nevertheless, the following FillPDF forms will not work until their respective PDF templates have been moved to an existing file scheme:<br />@list', [
'@list' => \Drupal::service('renderer')->renderPlain($list),
]);
$this->messenger()->addError(\Drupal::service('renderer')->renderPlain($error_message));
}
$this->messenger()->addError(new FormattableMarkup($error_message, []));
$this->logger('fillpdf')->critical('File storage %previous_scheme is no longer available.' . $count ? " $count FillPDF forms are defunct." : '', [
'%previous_scheme' => $template_scheme . '://',
]);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment