From 9af082e54cfe766b4e26afcb9b1b698d84434b68 Mon Sep 17 00:00:00 2001 From: Awilum Date: Sun, 5 Jun 2022 13:32:07 +0300 Subject: [PATCH] feat(helpers): add ability to set status code for redirect helper --- src/flextype/helpers/url.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/flextype/helpers/url.php b/src/flextype/helpers/url.php index 91d14633..2caef6f9 100644 --- a/src/flextype/helpers/url.php +++ b/src/flextype/helpers/url.php @@ -208,15 +208,17 @@ if (! function_exists('redirect')) { /** * Redirect. * - * @param string $routeName Route name - * @param array $data Route placeholders - * @param array $queryParams Query parameters + * @param string $routeName Route name. + * @param array $data Route placeholders. + * @param array $queryParams Query parameters. + * @param int $status Status code. * * @return Response */ - function redirect(string $routeName, array $data = [], array $queryParams = []): Response + function redirect(string $routeName, array $data = [], array $queryParams = [], int $status = 301): Response { $response = new Response(); + $response = $response->withStatus($status); $response = $response->withHeader('Location', urlFor($routeName, $data, $queryParams)); return $response;