Documentation

RedirectPlugin
in package
implements EventSubscriberInterface

Plugin to implement HTTP redirects. Can redirect like a web browser or using strict RFC 2616 compliance

Table of Contents

Interfaces

EventSubscriberInterface
An EventSubscriber knows himself what events he is interested in.

Constants

DISABLE  = 'redirect.disable'
MAX_REDIRECTS  = 'redirect.max'
PARENT_REQUEST  = 'redirect.parent_request'
REDIRECT_COUNT  = 'redirect.count'
STRICT_REDIRECTS  = 'redirect.strict'

Properties

$defaultMaxRedirects  : int

Methods

cleanupRequest()  : mixed
Clean up the parameters of a request when it is cloned
getSubscribedEvents()  : array<string|int, mixed>
Returns an array of event names this subscriber wants to listen to.
onRequestSent()  : mixed
Called when a request receives a redirect response
createRedirectRequest()  : RequestInterface
Create a redirect request for a specific request object
getOriginalRequest()  : RequestInterface
Get the original request that initiated a series of redirects
prepareRedirection()  : RequestInterface
Prepare the request for redirection and enforce the maximum number of allowed redirects per client
sendRedirectRequest()  : mixed
Send a redirect request and handle any errors
throwTooManyRedirectsException()  : mixed
Throw a too many redirects exception for a request

Constants

PARENT_REQUEST

public mixed PARENT_REQUEST = 'redirect.parent_request'

STRICT_REDIRECTS

public mixed STRICT_REDIRECTS = 'redirect.strict'

Properties

$defaultMaxRedirects

protected int $defaultMaxRedirects = 5

Default number of redirects allowed when no setting is supplied by a request

Methods

cleanupRequest()

Clean up the parameters of a request when it is cloned

public cleanupRequest(Event $event) : mixed
Parameters
$event : Event

Event emitted

getSubscribedEvents()

Returns an array of event names this subscriber wants to listen to.

public static getSubscribedEvents() : array<string|int, mixed>

The array keys are event names and the value can be:

  • The method name to call (priority defaults to 0)
  • An array composed of the method name to call and the priority
  • An array of arrays composed of the method names to call and respective priorities, or 0 if unset

For instance:

  • array('eventName' => 'methodName')
  • array('eventName' => array('methodName', $priority))
  • array('eventName' => array(array('methodName1', $priority), array('methodName2')))
Return values
array<string|int, mixed>

The event names to listen to

onRequestSent()

Called when a request receives a redirect response

public onRequestSent(Event $event) : mixed
Parameters
$event : Event

Event emitted

createRedirectRequest()

Create a redirect request for a specific request object

protected createRedirectRequest(RequestInterface $request, int $statusCode, string $location, RequestInterface $original) : RequestInterface

Takes into account strict RFC compliant redirection (e.g. redirect POST with POST) vs doing what most clients do (e.g. redirect POST with GET).

Parameters
$request : RequestInterface

Request being redirected

$statusCode : int

Status code of the redirect

$location : string

Location header of the redirect

$original : RequestInterface

Original request

Tags
throws
CouldNotRewindStreamException

If the body needs to be rewound but cannot

Return values
RequestInterface

Returns a new redirect request


        
On this page

Search results