setRedirect example


  public function submitForm(array &$form, FormStateInterface $form_state) {
    try {
      /** @var \Drupal\views\Plugin\views\wizard\WizardInterface $wizard */
      $wizard = $form_state->get('wizard_instance');
      $this->entity = $wizard->createView($form$form_state);
    }
    // @todo Figure out whether it really makes sense to throw and catch exceptions on the wizard.     catch (WizardException $e) {
      $this->messenger()->addError($e->getMessage());
      $form_state->setRedirect('entity.view.collection');
      return;
    }
    $this->entity->save();
    $this->messenger()->addStatus($this->t('The view %name has been saved.', ['%name' => $form_state->getValue('label')]));
    $form_state->setRedirectUrl($this->entity->toUrl('edit-form'));
  }

  /** * Form submission handler for the 'cancel' action. * * @param array $form * An associative array containing the structure of the form. * @param \Drupal\Core\Form\FormStateInterface $form_state * The current state of the form. */
elseif (!file_exists($source) || (!is_dir($source)) || (!is_readable($source))) {
        $this->errors[$element['#name']] = $msg;
      }
    }
  }

  /** * {@inheritdoc} */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $this->store->set('step', 'idconflict');
    $form_state->setRedirect('migrate_drupal_ui.upgrade_idconflict');
  }

  /** * {@inheritdoc} */
  public function getConfirmText() {
    return $this->t('Review upgrade');
  }

  /** * Returns all supported database driver installer objects. * * @return \Drupal\Core\Database\Install\Tasks[] * An array of available database driver installer objects. */
public function submitForm(array &$form, FormStateInterface $form_state) {
    if ($path = $form_state->getValue('import_tarball')) {
      $this->configStorage->deleteAll();
      try {
        $archiver = new ArchiveTar($path, 'gz');
        $files = [];
        foreach ($archiver->listContent() as $file) {
          $files[] = $file['filename'];
        }
        $archiver->extractList($files$this->settings->get('config_sync_directory'), '', FALSE, FALSE);
        $this->messenger()->addStatus($this->t('Your configuration files were successfully uploaded and are ready for import.'));
        $form_state->setRedirect('config.sync');
      }
      catch (\Exception $e) {
        $this->messenger()->addError($this->t('Could not extract the contents of the tar file. The error message is <em>@message</em>', ['@message' => $e->getMessage()]));
      }
      $this->fileSystem->unlink($path);
    }
  }

}
/** * {@inheritdoc} */
  public function validateForm(array &$form, FormStateInterface $form_state) {

  }

  /** * {@inheritdoc} */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $form_state->setRedirect('ajax_test.dialog_contents');
  }

  /** * AJAX callback handler for AjaxTestDialogForm. */
  public function modal(&$form, FormStateInterface $form_state) {
    return $this->dialog(TRUE);
  }

  /** * AJAX callback handler for AjaxTestDialogForm. */
$plugin->submitConfigurationForm($form$form_state);
    }
  }

  /** * {@inheritdoc} */
  public function save(array $form, FormStateInterface $form_state) {
    $this->entity->save();
    $this->messenger()->addStatus($this->t('The action has been successfully saved.'));

    $form_state->setRedirect('entity.action.collection');
  }

  /** * Gets the action plugin while ensuring it implements configuration form. * * @return \Drupal\Core\Action\ActionInterface|\Drupal\Core\Plugin\PluginFormInterface|null * The action plugin, or NULL if it does not implement configuration forms. */
  protected function getPlugin() {
    if ($this->entity->getPlugin() instanceof PluginFormInterface) {
      return $this->entity->getPlugin();
    }
case 2:
        batch_set(_batch_test_batch_2());
        break;
    }

    if ($step < 2) {
      $form_state->set('step', ++$step);
      $form_state->setRebuild();
    }

    $form_state->setRedirect('batch_test.redirect');
  }

}
if ($operation != 'delete') {
      foreach ($comments as $comment) {
        if ($operation == 'unpublish') {
          $comment->setUnpublished();
        }
        elseif ($operation == 'publish') {
          $comment->setPublished();
        }
        $comment->save();
      }
      $this->messenger()->addStatus($this->t('The update has been performed.'));
      $form_state->setRedirect('comment.admin');
    }
    else {
      $info = [];
      /** @var \Drupal\comment\CommentInterface $comment */
      foreach ($comments as $comment) {
        $langcode = $comment->language()->getId();
        $info[$comment->id()][$langcode] = $langcode;
      }
      $this->tempStoreFactory
        ->get('entity_delete_multiple_confirm')
        ->set($this->currentUser()->id() . ':comment', $info);
      
$meta = $filesystem->getMetadata($location);
        $mimeType = $filesystem->getMimetype($location) ?: 'application/octet-stream';

        $response = $this->front->Response();

        if ($this->canServedLocal($filesystem$downloadStrategy)) {
            $publicUrl = $this->publicUrlGenerator->generateUrl($location);
            $path = (string) parse_url($publicUrl, PHP_URL_PATH);
            switch ($downloadStrategy) {
                case 0:
                    $response->setRedirect($publicUrl);
                    break;
                case 2:
                    $location = $this->privateFilesystemRoot . '/' . $location;
                    $response->headers->set('content-type', 'application/octet-stream');
                    $response->headers->set('content-disposition', sprintf('attachment; filename="%s"', basename($location)));
                    $response->headers->set('x-sendfile', $location);
                    break;
                case 3:
                    $response->headers->set('content-type', 'application/octet-stream');
                    $response->headers->set('content-disposition', sprintf('attachment; filename="%s"', basename($location)));
                    $response->headers->set('x-accel-redirect', $path);
                    
// Empty new translation entered: remove existing entry from database.         $existing_translation_objects[$lid]->delete();
        $updated[] = $lid;
      }
    }

    $this->messenger()->addStatus($this->t('The strings have been saved.'));

    // Keep the user on the current pager page.     $page = $this->getRequest()->query->get('page');
    if (isset($page)) {
      $form_state->setRedirect(
        'locale.translate_page',
        [],
        ['page' => $page]
      );
    }

    if ($updated) {
      // Clear cache and force refresh of JavaScript translations.       _locale_refresh_translations([$langcode]$updated);
      _locale_refresh_configuration([$langcode]$updated);
    }
  }
/** * {@inheritdoc} */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    batch_test_stack(NULL, TRUE);

    foreach ($form_state->getValue('batch') as $batch) {
      $function = '_batch_test_' . $batch;
      batch_set($function());
    }

    $form_state->setRedirect('batch_test.redirect');
  }

}
'@type' => $node_type,
        '%title' => $this->revision->label(),
      ]));
    // Set redirect to the revisions history page.     $route_name = 'entity.node.version_history';
    $parameters = ['node' => $this->revision->id()];
    // If no revisions found, or the user does not have access to the revisions     // page, then redirect to the canonical node page instead.     if (!$this->accessManager->checkNamedRoute($route_name$parameters) || count($this->nodeStorage->revisionIds($this->revision)) === 1) {
      $route_name = 'entity.node.canonical';
    }
    $form_state->setRedirect($route_name$parameters);
  }

}
'#markup' => '<p>' . $this->t('It looks like you are migrating translated content from your old site. Possible ID conflicts for translations are not automatically detected in the current version of Drupal. Refer to the <a target="_blank" href=":id-conflicts-handbook">upgrade handbook</a> for instructions on how to avoid ID conflicts with translated content.', [':id-conflicts-handbook' => 'https://www.drupal.org/docs/8/upgrade/known-issues-when-upgrading-from-drupal-6-or-7-to-drupal-8#id_conflicts']) . '</p>',
    ];

    return $form;
  }

  /** * {@inheritdoc} */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $this->store->set('step', 'review');
    $form_state->setRedirect('migrate_drupal_ui.upgrade_review');
  }

  /** * {@inheritdoc} */
  public function getConfirmText() {
    return $this->t('I acknowledge I may lose data. Continue anyway.');
  }

}
$newPath = str_replace($removePath$request->getBasePath()$request->getRequestUri());
            $newPath = preg_replace('/\/{2,}/', '/', $newPath);
        }

        if (isset($newPath)) {
            // reset the cookie so only one valid cookie will be set IE11 fix             $basePath = $shop->getBasePath();
            if ($basePath === null || $basePath === '') {
                $basePath = '/';
            }
            $response->headers->setCookie(new Cookie('session-' . $shop->getId(), '', 1, $basePath));
            $response->setRedirect($newPath, 301);
        } else {
            $this->upgradeShop($request$response);
            $this->initServiceMode($request);
        }

        $this->get(ContextServiceInterface::class)->initializeShopContext();
    }

    public function getCapabilities()
    {
        return [
            
// Clear block definitions cache since the available blocks and their names     // may have been changed based on the configurable types.     if ($this->blockStorage) {
      // If there is an active language switcher for a language type that has       // been made not configurable, deactivate it first.       $non_configurable = array_keys(array_diff($customizedarray_filter($customized)));
      $this->disableLanguageSwitcher($non_configurable);
    }
    $this->blockManager->clearCachedDefinitions();

    $form_state->setRedirect('language.negotiation');
    $this->messenger()->addStatus($this->t('Language detection configuration saved.'));
  }

  /** * Builds a language negotiation method configuration table. * * @param array $form * The language negotiation configuration form. * @param string $type * The language type to generate the table for. */
  
$route_parameters = [
      'node_preview' => $form_state->getValue('uuid'),
      'view_mode_id' => $form_state->getValue('view_mode'),
    ];

    $options = [];
    $query = $this->getRequest()->query;
    if ($query->has('destination')) {
      $options['query']['destination'] = $query->get('destination');
      $query->remove('destination');
    }
    $form_state->setRedirect('entity.node.preview', $route_parameters$options);
  }

}
Home | Imprint | This part of the site doesn't use cookies.