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:
parent
a4c02ed249
commit
8d2d095b8e
@ -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()]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -55,17 +55,25 @@ class OCActivityForm extends ContentEntityForm {
|
||||
|
||||
switch ($status) {
|
||||
case SAVED_NEW:
|
||||
drupal_set_message($this->t('Created the %label Activity.', [
|
||||
'%label' => $entity->label(),
|
||||
drupal_set_message($this->t('Created the %bundle.', [
|
||||
'%bundle' => $entity->bundle(),
|
||||
]));
|
||||
break;
|
||||
|
||||
default:
|
||||
drupal_set_message($this->t('Saved the %label Activity.', [
|
||||
'%label' => $entity->label(),
|
||||
drupal_set_message($this->t('Saved the %bundle.', [
|
||||
'%bundle' => $entity->bundle(),
|
||||
]));
|
||||
}
|
||||
$form_state->setRedirect('entity.oc_activity.canonical', ['oc_activity' => $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 activity entities')) {
|
||||
drupal_set_message($this->t('The %bundle is now unpublished & hidden from you.', [
|
||||
'%bundle' => $entity->bundle(),
|
||||
]));
|
||||
$form_state->setRedirect('<front>');
|
||||
} else {
|
||||
$form_state->setRedirect('entity.oc_activity.canonical', ['oc_activity' => $entity->id()]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -60,7 +60,10 @@ class OCActorForm extends ContentEntityForm {
|
||||
}
|
||||
// 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 actor entities')) {
|
||||
$form_state->setRedirect('entity.node.canonical', ['node' => 1]);
|
||||
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_actor.canonical', ['oc_actor' => $entity->id()]);
|
||||
}
|
||||
|
@ -60,7 +60,15 @@ class OCEventForm extends ContentEntityForm {
|
||||
'%label' => $entity->label(),
|
||||
]));
|
||||
}
|
||||
$form_state->setRedirect('entity.oc_event.canonical', ['oc_event' => $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 event 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_event.canonical', ['oc_event' => $entity->id()]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -81,7 +81,15 @@ class OCOrganisationForm extends ContentEntityForm {
|
||||
'%label' => $entity->label(),
|
||||
]));
|
||||
}
|
||||
$form_state->setRedirect('entity.oc_organisation.canonical', ['oc_organisation' => $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 organisation 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_organisation.canonical', ['oc_organisation' => $entity->id()]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user