When a user who can't see unpublished entities unpublishes one, it redirects to the home page and displays a message.
This commit is contained in:
@ -65,7 +65,15 @@ class OCCaseForm extends ContentEntityForm {
|
||||
'%label' => $entity->label(),
|
||||
]));
|
||||
}
|
||||
$form_state->setRedirect('entity.oc_case.canonical', ['oc_case' => $entity->id()]);
|
||||
// If you have unpublished the entity and you can't see unpublished entities, redirect to a more informative message than just "Access Denied".
|
||||
if (!$form_state->getValue('status')['value'] && !\Drupal::currentUser()->hasPermission('view unpublished case entities')) {
|
||||
drupal_set_message($this->t('The record for "%label" is now unpublished & hidden from you.', [
|
||||
'%label' => $entity->label(),
|
||||
]));
|
||||
$form_state->setRedirect('<front>');
|
||||
} else {
|
||||
$form_state->setRedirect('entity.oc_case.canonical', ['oc_case' => $entity->id()]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user