1
0
mirror of https://github.com/flextype/flextype.git synced 2025-08-06 13:16:45 +02:00

feat(helpers): add ability to set status code for redirect helper

This commit is contained in:
Awilum
2022-06-05 13:32:07 +03:00
parent acf6d5161c
commit 9af082e54c

View File

@@ -208,15 +208,17 @@ if (! function_exists('redirect')) {
/**
* Redirect.
*
* @param string $routeName Route name
* @param array<string, string> $data Route placeholders
* @param array<string, string> $queryParams Query parameters
* @param string $routeName Route name.
* @param array<string, string> $data Route placeholders.
* @param array<string, string> $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;