fixed redirect after deleting activity - defaults to target if there's no case
This commit is contained in:
parent
fb2249d9bd
commit
34b7a1c7c9
@ -7,6 +7,7 @@ declare(strict_types = 1);
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
use Drupal\Core\Routing\RouteMatchInterface;
|
use Drupal\Core\Routing\RouteMatchInterface;
|
||||||
|
use PHPUnit\Framework\Constraint\IsEmpty;
|
||||||
|
|
||||||
use function PHPUnit\Framework\isEmpty;
|
use function PHPUnit\Framework\isEmpty;
|
||||||
|
|
||||||
@ -183,9 +184,16 @@ function opencase_cases_form_alter(&$form, &$form_state, $form_id) {
|
|||||||
function _opencase_cases_redirect_to_home($form, &$form_state) {
|
function _opencase_cases_redirect_to_home($form, &$form_state) {
|
||||||
$form_state->setRedirect('<front>');
|
$form_state->setRedirect('<front>');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Upon deletion of an activity, go to the related case if there is one, otherwise to its target.
|
||||||
function _opencase_cases_delete_activity_redirect($form, &$form_state) {
|
function _opencase_cases_delete_activity_redirect($form, &$form_state) {
|
||||||
|
if (!IsEmpty($form_state->getFormObject()->getEntity()->oc_case)) {
|
||||||
$case_id = $form_state->getFormObject()->getEntity()->oc_case->target_id;
|
$case_id = $form_state->getFormObject()->getEntity()->oc_case->target_id;
|
||||||
$form_state->setRedirect('entity.oc_case.canonical', ['oc_case' => $case_id]);
|
$form_state->setRedirect('entity.oc_case.canonical', ['oc_case' => $case_id]);
|
||||||
|
} else {
|
||||||
|
$target_actor_id = $form_state->getFormObject()->getEntity()->oc_target->target_id;
|
||||||
|
$form_state->setRedirect('entity.oc_actor.canonical', ['oc_actor' => $target_actor_id]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Implements hook_theme_suggestions_HOOK().
|
* Implements hook_theme_suggestions_HOOK().
|
||||||
|
Reference in New Issue
Block a user