You are here

public static function LogintobogganUtility::processRedirect in LoginToboggan 8

Returns a redirect URL.

Parameters

string $redirect: Redirect location.

object $account: User account.

Return value

\Drupal\Core\Url returns a URL object.

2 calls to LogintobogganUtility::processRedirect()
LogintobogganController::logintobogganValidateEmail in src/Controller/LogintobogganController.php
This will return the output of the page.
LogintobogganRegister::save in src/Form/LogintobogganRegister.php
Form submission handler for the 'save' action.

File

src/Utility/LogintobogganUtility.php, line 37

Class

LogintobogganUtility
Class for utility methods.

Namespace

Drupal\logintoboggan\Utility

Code

public static function processRedirect($redirect, $account) {
  $variables = [
    '%uid' => $account
      ->id(),
  ];
  $redirect = parse_url(urldecode(strtr($redirect, $variables)));
  $redirect = UrlHelper::parse($redirect['path']);

  // If there's a path set, override the destination parameter if necessary.
  if ($redirect['path'] && \Drupal::config('logintoboggan.settings')
    ->get('override_destination_parameter')) {
    \Drupal::request()->query
      ->remove('destination');
  }

  // Explicitly create query and fragment elements if not present already.
  $query = isset($redirect['query']) ? $redirect['query'] : [];
  $fragment = isset($redirect['fragment']) ? $redirect['fragment'] : '';
  return Url::fromUserInput($redirect['path'], [
    'query' => $query,
    'fragment' => $fragment,
  ]);
}