redirect to home after deleting case or actor

also changed contextual menu code for cases when the actor whose case it is has been deleted
This commit is contained in:
naomi 2018-07-18 22:15:45 +02:00
parent ddab3e450a
commit 33feac1977
2 changed files with 18 additions and 1 deletions

View File

@ -165,3 +165,19 @@ function opencase_entity_field_access($operation, \Drupal\Core\Field\FieldDefini
}
return AccessResult::neutral();
}
/**
* Implementation of hook_form_alter()
* After deleting an actor or a
*/
function opencase_form_alter(&$form, &$form_state, $form_id) {
if (preg_match('/oc_actor_.*_delete_form/', $form_id) or (preg_match('/oc_case_.*_delete_form/', $form_id))) {
$form['actions']['submit']['#submit'][] = '_opencase_delete_case_redirect';
}
}
function _opencase_delete_case_redirect($form, &$form_state) {
$form_state->setRedirect('view.cases.page_2'); // redirect to view of all cases
}

View File

@ -101,7 +101,8 @@ class ContextualMenu extends BlockBase {
private function casePage() {
$case = \Drupal::routeMatch()->getParameter('oc_case');
$actor_id = \Drupal::service('user.private_tempstore')->get('opencase')->get('actor_id');
if ($actor_id) {
$actor = \Drupal::entityTypeManager()->getStorage('oc_actor')->load($actor_id);
if ($actor) {
$actor = \Drupal::entityTypeManager()->getStorage('oc_actor')->load($actor_id);
$caseListLink = $this->getCaseListLink($actor);
} else {