diff --git a/opencase.module b/opencase.module index f858259..9aeb496 100644 --- a/opencase.module +++ b/opencase.module @@ -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 +} diff --git a/src/Plugin/Block/ContextualMenu.php b/src/Plugin/Block/ContextualMenu.php index e2951c4..e1fd009 100644 --- a/src/Plugin/Block/ContextualMenu.php +++ b/src/Plugin/Block/ContextualMenu.php @@ -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 {