You are here

public function FieldRedirectionResult::asRedirectResponse in Field Redirection 8.2

Gets the result as a redirect response.

Parameters

int $status_code: Status code.

array $headers: Additional headers.

Return value

\Symfony\Component\HttpFoundation\RedirectResponse Redirect response.

Throws

\LogicException When the result should not redirect.

File

src/FieldRedirectionResult.php, line 61

Class

FieldRedirectionResult
Defines a value object for a field redirection result.

Namespace

Drupal\field_redirection

Code

public function asRedirectResponse($status_code = 302, array $headers = []) {
  return new RedirectResponse($this
    ->getRedirectUrl()
    ->toString(), $status_code, $headers);
}