TrustedRedirectResponse
class TrustedRedirectResponse extends CacheableSecuredRedirectResponse (View source)
Provides a redirect response which contains trusted URLs.
Use this class in case you know that you want to redirect to an external URL.
Traits
Provides a trait which ensures that a URL is safe to redirect to.
Provides an implementation of CacheableResponseInterface.
Properties
| protected CacheableMetadata | $cacheabilityMetadata | The cacheability metadata. |
from CacheableResponseTrait |
| protected RequestContext | $requestContext | The request context. |
from LocalAwareRedirectResponseTrait |
| protected string[] | $trustedUrls | A list of trusted URLs, which are safe to redirect to. |
Methods
Copies an existing redirect response into a safe one.
Copies over the values from the given response.
Returns whether the URL is considered as safe to redirect to.
Returns the request context.
{@inheritdoc}
Sets the target URL to a trusted URL.
Details
static SecuredRedirectResponse
createFromRedirectResponse(RedirectResponse $response)
Copies an existing redirect response into a safe one.
The safe one cannot accidentally redirect to an external URL, unless actively wanted (see TrustedRedirectResponse).
protected
fromResponse(RedirectResponse $response)
Copies over the values from the given response.
setTargetUrl($url)
{@inheritdoc}
protected bool
isSafe(string $url)
Returns whether the URL is considered as safe to redirect to.
addCacheableDependency($dependency)
{@inheritdoc}
getCacheableMetadata()
{@inheritdoc}
protected bool
isLocal(string $url)
Determines whether a path is local.
protected RequestContext
getRequestContext()
Returns the request context.
$this
setRequestContext(RequestContext $request_context)
Sets the request context.
__construct($url, $status = 302, $headers = [])
{@inheritdoc}
$this
setTrustedTargetUrl(string $url)
Sets the target URL to a trusted URL.