class Redirector

Traits

Properties

static protected array $macros

The registered string macros.

from  Macroable
protected UrlGenerator $generator

The URL generator instance.

protected Store $session

The session store instance.

Methods

static void
macro(string $name, callable|object $macro)

Register a custom macro.

static void
mixin(object $mixin, bool $replace = true)

Mix another object into the class.

static bool
hasMacro(string $name)

Check if macro is registered.

static void
flushMacros()

Flush the existing macros.

static mixed
__callStatic(string $method, array $parameters)

Dynamically handle calls to the class.

mixed
__call(string $method, array $parameters)

Dynamically handle calls to the class.

__construct(UrlGenerator $generator)

Create a new Redirector instance.

back(int $status = 302, array $headers = [], bool|string $fallback = false)

Create a new redirect response to the previous location.

refresh(int $status = 302, array $headers = [])

Create a new redirect response to the current URI.

guest(string $path, int $status = 302, array $headers = [], bool|null $secure = null)

Create a new redirect response, while putting the current URL in the session.

intended(string $default = '/', int $status = 302, array $headers = [], bool|null $secure = null)

Create a new redirect response to the previously intended location.

to(string $path, int $status = 302, array $headers = [], bool|null $secure = null)

Create a new redirect response to the given path.

away(string $path, int $status = 302, array $headers = [])

Create a new redirect response to an external URL (no validation).

secure(string $path, int $status = 302, array $headers = [])

Create a new redirect response to the given HTTPS path.

route(BackedEnum|string $route, array|string $parameters = [], int $status = 302, array $headers = [])

Create a new redirect response to a named route.

signedRoute(BackedEnum|string $route, array|string $parameters = [], DateInterval|DateTimeInterface|int|null $expiration = null, int $status = 302, array $headers = [])

Create a new redirect response to a signed named route.

temporarySignedRoute(BackedEnum|string $route, DateInterval|DateTimeInterface|int $expiration, array $parameters = [], int $status = 302, array $headers = [])

Create a new redirect response to a temporary signed named route.

action(array|string $action, array|string $parameters = [], int $status = 302, array $headers = [])

Create a new redirect response to a controller action.

createRedirect(string $path, int $status, array $headers)

Create a new redirect response.

getUrlGenerator()

Get the URL generator instance.

void
setSession(Store $session)

Set the active session store.

string|null
getIntendedUrl()

Get the "intended" URL from the session.

setIntendedUrl(string $url)

Set the "intended" URL in the session.

static void
flushState()

Flush all static state.

Details

in Macroable at line 28
static void macro(string $name, callable|object $macro)

Register a custom macro.

Boot-only. Macros persist in a static property for the worker lifetime and apply to every subsequent call on the macroable class.

Parameters

string $name
callable|object $macro

Return Value

void

in Macroable at line 41
static void mixin(object $mixin, bool $replace = true)

Mix another object into the class.

Boot-only. Delegates to macro() for each method; registered macros persist in a static property for the worker lifetime.

Parameters

object $mixin
bool $replace

Return Value

void

Exceptions

ReflectionException

in Macroable at line 57
static bool hasMacro(string $name)

Check if macro is registered.

Parameters

string $name

Return Value

bool

in Macroable at line 68
static void flushMacros()

Flush the existing macros.

Boot or tests only. Clears worker-wide macros; concurrent coroutines may resolve different methods depending on timing.

Return Value

void

in Macroable at line 78
static mixed __callStatic(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

in Macroable at line 103
mixed __call(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

at line 31
__construct(UrlGenerator $generator)

Create a new Redirector instance.

Parameters

UrlGenerator $generator

at line 39
RedirectResponse back(int $status = 302, array $headers = [], bool|string $fallback = false)

Create a new redirect response to the previous location.

Parameters

int $status
array $headers
bool|string $fallback

Return Value

RedirectResponse

at line 47
RedirectResponse refresh(int $status = 302, array $headers = [])

Create a new redirect response to the current URI.

Parameters

int $status
array $headers

Return Value

RedirectResponse

at line 55
RedirectResponse guest(string $path, int $status = 302, array $headers = [], bool|null $secure = null)

Create a new redirect response, while putting the current URL in the session.

Parameters

string $path
int $status
array $headers
bool|null $secure

Return Value

RedirectResponse

at line 73
RedirectResponse intended(string $default = '/', int $status = 302, array $headers = [], bool|null $secure = null)

Create a new redirect response to the previously intended location.

Parameters

string $default
int $status
array $headers
bool|null $secure

Return Value

RedirectResponse

at line 83
RedirectResponse to(string $path, int $status = 302, array $headers = [], bool|null $secure = null)

Create a new redirect response to the given path.

Parameters

string $path
int $status
array $headers
bool|null $secure

Return Value

RedirectResponse

at line 91
RedirectResponse away(string $path, int $status = 302, array $headers = [])

Create a new redirect response to an external URL (no validation).

Parameters

string $path
int $status
array $headers

Return Value

RedirectResponse

at line 99
RedirectResponse secure(string $path, int $status = 302, array $headers = [])

Create a new redirect response to the given HTTPS path.

Parameters

string $path
int $status
array $headers

Return Value

RedirectResponse

at line 107
RedirectResponse route(BackedEnum|string $route, array|string $parameters = [], int $status = 302, array $headers = [])

Create a new redirect response to a named route.

Parameters

BackedEnum|string $route
array|string $parameters
int $status
array $headers

Return Value

RedirectResponse

at line 115
RedirectResponse signedRoute(BackedEnum|string $route, array|string $parameters = [], DateInterval|DateTimeInterface|int|null $expiration = null, int $status = 302, array $headers = [])

Create a new redirect response to a signed named route.

Parameters

BackedEnum|string $route
array|string $parameters
DateInterval|DateTimeInterface|int|null $expiration
int $status
array $headers

Return Value

RedirectResponse

at line 123
RedirectResponse temporarySignedRoute(BackedEnum|string $route, DateInterval|DateTimeInterface|int $expiration, array $parameters = [], int $status = 302, array $headers = [])

Create a new redirect response to a temporary signed named route.

Parameters

BackedEnum|string $route
DateInterval|DateTimeInterface|int $expiration
array $parameters
int $status
array $headers

Return Value

RedirectResponse

at line 131
RedirectResponse action(array|string $action, array|string $parameters = [], int $status = 302, array $headers = [])

Create a new redirect response to a controller action.

Parameters

array|string $action
array|string $parameters
int $status
array $headers

Return Value

RedirectResponse

at line 139
protected RedirectResponse createRedirect(string $path, int $status, array $headers)

Create a new redirect response.

Parameters

string $path
int $status
array $headers

Return Value

RedirectResponse

at line 153
UrlGenerator getUrlGenerator()

Get the URL generator instance.

Return Value

UrlGenerator

at line 161
void setSession(Store $session)

Set the active session store.

Parameters

Store $session

Return Value

void

at line 169
string|null getIntendedUrl()

Get the "intended" URL from the session.

Return Value

string|null

at line 179
Redirector setIntendedUrl(string $url)

Set the "intended" URL in the session.

Parameters

string $url

Return Value

Redirector

at line 189
static void flushState()

Flush all static state.

Return Value

void