Skip to content
Snippets Groups Projects
Commit 19771aae authored by Andrei Mateescu's avatar Andrei Mateescu
Browse files

Issue #3408762 by swentel, amateescu: Different message on delete form...

Issue #3408762 by swentel, amateescu: Different message on delete form depending on restore permission
parent 5f509a1e
No related branches found
Tags 8.x-1.7
No related merge requests found
Pipeline #128599 passed with warnings with stages
in 2 minutes and 54 seconds
......@@ -222,12 +222,26 @@ function trash_form_alter(&$form, FormStateInterface $form_state, $form_id) {
])->toString(),
];
// Use different messages based on the user's access level.
if (\Drupal::currentUser()->hasPermission('restore ' . $entity_type->id() . ' entities')) {
$entity_delete_label = t('Deleting this @label will move it to the <a href=":link">trash</a>. You can restore it from the trash at a later date if necessary.', $params);
$entity_multiple_delete_label = t('Deleting these @label will move them to the <a href=":link">trash</a>. You can restore them from the trash at a later date if necessary.', $params);
}
elseif (\Drupal::currentUser()->hasPermission('access trash')) {
$entity_delete_label = t('Deleting this @label will move it to the <a href=":link">trash</a>.', $params);
$entity_multiple_delete_label = t('Deleting these @label will move them to the <a href=":link">trash</a>.', $params);
}
else {
$entity_delete_label = t('Deleting this @label will move it to the trash.', $params);
$entity_multiple_delete_label = t('Deleting these @label will move them to the trash.', $params);
}
if ($form['description']['#markup']->getUntranslatedString() === 'This action cannot be undone.') {
if ($is_entity_delete_form) {
$form['description']['#markup'] = t('Deleting this @label will move it to the <a href=":link">trash</a>. You can restore it from the trash at a later date if necessary.', $params);
$form['description']['#markup'] = $entity_delete_label;
}
elseif ($is_entity_multiple_delete_form) {
$form['description']['#markup'] = t('Deleting these @label will move them to the <a href=":link">trash</a>. You can restore them from the trash at a later date if necessary.', $params);
$form['description']['#markup'] = $entity_multiple_delete_label;
}
}
}
......
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