getRedirectUrl example

/** * Assert that a given response was a redirect * and it was redirect to a specific URI. * * @throws Exception */
    public function assertRedirectTo(string $uri)
    {
        $this->assertRedirect();

        $uri         = trim(strtolower($uri));
        $redirectUri = strtolower($this->getRedirectUrl());

        $matches = $uri === $redirectUri
                   || strtolower(site_url($uri)) === $redirectUri
                   || $uri === site_url($redirectUri);

        $this->assertTrue($matches, "Redirect URL `{$uri}` does not match `{$redirectUri}`");
    }

    /** * Assert that the given response was not a redirect. * * @throws Exception */
$this->stateMachineRegistry->transition(
                new Transition(
                    OrderTransactionDefinition::ENTITY_NAME,
                    $transaction->getOrderTransaction()->getId(),
                    $response->getStatus(),
                    'stateId'
                ),
                $salesChannelContext->getContext()
            );
        }

        return new RedirectResponse($response->getRedirectUrl());
    }

    public function finalize(AsyncPaymentTransactionStruct $transaction, Request $request, SalesChannelContext $salesChannelContext): void
    {
        $queryParameters = $request->query->all();
        unset($queryParameters['_sw_payment_token']);

        $payload = $this->buildFinalizePayload($transaction$queryParameters);
        $app = $this->getAppPaymentMethod($transaction->getOrderTransaction())->getApp();
        if ($app === null) {
            throw PaymentException::asyncFinalizeInterrupted($transaction->getOrderTransaction()->getId(), 'App not defined');
        }
/** * {@inheritdoc} */
  public function getDescription() {
    return $this->t('All customizations will be removed. This action cannot be undone.');
  }

  /** * {@inheritdoc} */
  public function getCancelUrl() {
    return $this->sectionStorage->getRedirectUrl();
  }

  /** * {@inheritdoc} */
  public function buildForm(array $form, FormStateInterface $form_state, SectionStorageInterface $section_storage = NULL) {
    if (!$section_storage instanceof DefaultsSectionStorageInterface) {
      throw new \InvalidArgumentException(sprintf('The section storage with type "%s" and ID "%s" does not provide defaults', $section_storage->getStorageType()$section_storage->getStorageId()));
    }

    $this->sectionStorage = $section_storage;
    
if (empty($route)) {
            $route = 'frontend.home.page';
        }

        $params = $request->get('redirectParameters', '[]');

        if (\is_string($params)) {
            $params = json_decode($params, true);
        }

        if ($newTokenResponse->getRedirectUrl() === null) {
            return $this->redirectToRoute($route$params);
        }

        /* * possible domains * * http://shopware.de/de * http://shopware.de/en * http://shopware.de/fr * * http://shopware.fr * http://shopware.com * http://shopware.de * * http://color.com * http://farben.de * http://couleurs.fr * * http://localhost/development/public/de * http://localhost/development/public/en * http://localhost/development/public/fr * http://localhost/development/public/de-DE * * http://localhost:8080 * http://localhost:8080/en * http://localhost:8080/fr * http://localhost:8080/de-DE */
public function redirectOnSubmit(array $form, FormStateInterface $form_state) {
    $form_state->setRedirectUrl($this->sectionStorage->getLayoutBuilderUrl($form_state->getTriggeringElement()['#redirect']));
  }

  /** * {@inheritdoc} */
  public function save(array $form, FormStateInterface $form_state) {
    $return = $this->sectionStorage->save();
    $this->layoutTempstoreRepository->delete($this->sectionStorage);
    $this->messenger()->addMessage($this->t('The layout has been saved.'));
    $form_state->setRedirectUrl($this->sectionStorage->getRedirectUrl());
    return $return;
  }

  /** * Retrieves the section storage object. * * @return \Drupal\layout_builder\SectionStorageInterface * The section storage for the current form. */
  public function getSectionStorage() {
    return $this->sectionStorage;
  }

  }

  /** * {@inheritdoc} */
  public function save(array $form, FormStateInterface $form_state) {
    $return = parent::save($form$form_state);

    $this->layoutTempstoreRepository->delete($this->sectionStorage);
    $this->messenger()->addStatus($this->t('The layout override has been saved.'));
    $form_state->setRedirectUrl($this->sectionStorage->getRedirectUrl());
    return $return;
  }

  /** * {@inheritdoc} */
  protected function actions(array $form, FormStateInterface $form_state) {
    $actions = parent::actions($form$form_state);
    $actions['#attributes']['role'] = 'region';
    $actions['#attributes']['aria-label'] = $this->t('Layout Builder tools');
    $actions['submit']['#value'] = $this->t('Save layout');
    
$this->flood->register('contact', $this->config('contact.settings')->get('flood.interval'));
    if ($submission_message = $contact_form->getMessage()) {
      $this->messenger()->addStatus($submission_message);
    }

    // To avoid false error messages caused by flood control, redirect away from     // the contact form; either to the contacted user account or the front page.     if ($message->isPersonal() && $user->hasPermission('access user profiles')) {
      $form_state->setRedirectUrl($message->getPersonalRecipient()->toUrl());
    }
    else {
      $form_state->setRedirectUrl($contact_form->getRedirectUrl());
    }
  }

}
/** * {@inheritdoc} */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    // Remove all sections.     $this->sectionStorage
      ->removeAllSections()
      ->save();
    $this->layoutTempstoreRepository->delete($this->sectionStorage);

    $this->messenger->addMessage($this->t('The layout has been reverted back to defaults.'));
    $form_state->setRedirectUrl($this->sectionStorage->getRedirectUrl());
  }

}
    // @todo Remove this workaround once https://www.drupal.org/node/2897377 is     // fixed.     $form['#id'] = Html::getId($form_state->getBuildInfo()['form_id']);

    return $form;
  }

  /** * {@inheritdoc} */
  protected function successfulAjaxSubmit(array $form, FormStateInterface $form_state) {
    if ($redirect_url = $this->getRedirectUrl()) {
      $command = new RedirectCommand($redirect_url->setAbsolute()->toString());
    }
    else {
      // Settings Tray always provides a destination.       throw new \Exception("No destination provided by Settings Tray form");
    }
    $response = new AjaxResponse();
    return $response->addCommand($command);
  }

  /** * Gets the form's redirect URL from 'destination' provide in the request. * * @return \Drupal\Core\Url|null * The redirect URL or NULL if dialog should just be closed. */
/** * {@inheritdoc} */
  public function getQuestion() {
    return $this->t('Are you sure you want to discard your layout changes?');
  }

  /** * {@inheritdoc} */
  public function getCancelUrl() {
    return $this->sectionStorage->getRedirectUrl();
  }

  /** * {@inheritdoc} */
  public function buildForm(array $form, FormStateInterface $form_state, SectionStorageInterface $section_storage = NULL) {
    $this->sectionStorage = $section_storage;
    // Mark this as an administrative page for JavaScript ("Back to site" link).     $form['#attached']['drupalSettings']['path']['currentPathIsAdmin'] = TRUE;
    return parent::buildForm($form$form_state);
  }

  
$message = $this->getDeletionMessage();

    // Make sure that deleting a translation does not delete the whole entity.     if (!$entity->isDefaultTranslation()) {
      $untranslated_entity = $entity->getUntranslated();
      $untranslated_entity->removeTranslation($entity->language()->getId());
      $untranslated_entity->save();
      $form_state->setRedirectUrl($untranslated_entity->toUrl('canonical'));
    }
    else {
      $entity->delete();
      $form_state->setRedirectUrl($this->getRedirectUrl());
    }

    $this->messenger()->addStatus($message);
    $this->logDeletionMessage();
  }

  /** * {@inheritdoc} */
  public function getCancelUrl() {
    /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
    
Home | Imprint | This part of the site doesn't use cookies.