You are here

protected function ConditionRedirectTrait::setConditionRedirect in Block Visibility Groups 8

Ensure form redirects to the correct route.

Parameters

\Drupal\Core\Form\FormStateInterface $form_state: The form state.

2 calls to ConditionRedirectTrait::setConditionRedirect()
ConditionDeleteForm::submitForm in src/Form/ConditionDeleteForm.php
Form submission handler.
ConditionFormBase::submitForm in src/Form/ConditionFormBase.php
Form submission handler.

File

src/ConditionRedirectTrait.php, line 20

Class

ConditionRedirectTrait
Provides functionality to redirect conditions form to correct location.

Namespace

Drupal\block_visibility_groups

Code

protected function setConditionRedirect(FormStateInterface $form_state) {
  $redirect = $form_state
    ->getValue('bvg_redirect');
  if ($redirect == 'edit') {
    $form_state
      ->setRedirectUrl($this->block_visibility_group
      ->toUrl('edit-form'));
  }
  elseif ($redirect == 'layout') {
    $query = [
      'block_visibility_group' => $this->block_visibility_group
        ->id(),
      'show_conditions' => 1,
    ];
    $form_state
      ->setRedirect('block.admin_display', [], [
      'query' => $query,
    ]);
  }
}