AWS SDK for PHP 3.x (original) (raw)

HandlerList implementsCountable

Builds a single handler function from zero or more middleware functions and a handler. The handler function is then used to send command objects and return a promise that is resolved with an AWS result object.

The "front" of the list is invoked before the "end" of the list. You can add middleware to the front of the list using one of the "prepend" method, and the end of the list using one of the "append" method. The last function invoked in a handler list is the handler (a function that does not accept a next handler but rather is responsible for returning a promise that is fulfilled with an Aws\ResultInterface object).

Handlers are ordered using a "step" that describes the step at which the SDK is when sending a command. The available steps are:

Middleware can be registered with a name to allow you to easily add a middleware before or after another middleware by name. This also allows you to remove a middleware by name (in addition to removing by instance).

Table of Contents

Interfaces

Countable

Constants

ATTEMPT = 'attempt'

BUILD = 'build'

INIT = 'init'

SIGN = 'sign'

VALIDATE = 'validate'

Methods

__construct() : mixed

__toString() : string

Dumps a string representation of the list.

after() : mixed

Add a middleware after the given middleware by name.

appendAttempt() : mixed

Append a middleware to the attempt step.

appendBuild() : mixed

Append a middleware to the build step.

appendInit() : mixed

Append a middleware to the init step.

appendSign() : mixed

Append a middleware to the sign step.

appendValidate() : mixed

Append a middleware to the validate step.

before() : mixed

Add a middleware before the given middleware by name.

count() : int

hasHandler() : bool

Returns true if the builder has a handler.

hasMiddleware() : bool

Checks if a middleware exists. The middleware should have been added with a name in order to use this method.

interpose() : mixed

Interpose a function between each middleware (e.g., allowing for a trace through the middleware layers).

prependAttempt() : mixed

Prepend a middleware to the attempt step.

prependBuild() : mixed

Prepend a middleware to the build step.

prependInit() : mixed

Prepend a middleware to the init step.

prependSign() : mixed

Prepend a middleware to the sign step.

prependValidate() : mixed

Prepend a middleware to the validate step.

remove() : mixed

Remove a middleware by name or by instance from the list.

resolve() : callable

Compose the middleware and handler into a single callable function.

setHandler() : mixed

Set the HTTP handler that actually returns a response.

ATTEMPT

public mixed ATTEMPT = 'attempt'

BUILD

public mixed BUILD = 'build'

INIT

public mixed INIT = 'init'

SIGN

public mixed SIGN = 'sign'

VALIDATE

public mixed VALIDATE = 'validate'

__construct()

public __construct([callable $handler = null ]) : mixed

Parameters

$handler : callable = null

HTTP handler.

__toString()

Dumps a string representation of the list.

public __toString() : string

Return values

string

after()

Add a middleware after the given middleware by name.

public after(string|callable <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>f</mi><mi>i</mi><mi>n</mi><mi>d</mi><mi>N</mi><mi>a</mi><mi>m</mi><mi>e</mi><mo separator="true">,</mo><mi>s</mi><mi>t</mi><mi>r</mi><mi>i</mi><mi>n</mi><mi>g</mi></mrow><annotation encoding="application/x-tex">findName, string </annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.10764em;">f</span><span class="mord mathnormal">in</span><span class="mord mathnormal">d</span><span class="mord mathnormal" style="margin-right:0.10903em;">N</span><span class="mord mathnormal">am</span><span class="mord mathnormal">e</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">s</span><span class="mord mathnormal">t</span><span class="mord mathnormal" style="margin-right:0.02778em;">r</span><span class="mord mathnormal">in</span><span class="mord mathnormal" style="margin-right:0.03588em;">g</span></span></span></span>withName, callable $middleware) : mixed

Parameters

$findName : string|callable

Add after this

$withName : string

Optional name to give the middleware

$middleware : callable

Middleware to add.

appendAttempt()

Append a middleware to the attempt step.

public appendAttempt(callable <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>m</mi><mi>i</mi><mi>d</mi><mi>d</mi><mi>l</mi><mi>e</mi><mi>w</mi><mi>a</mi><mi>r</mi><mi>e</mi><mo stretchy="false">[</mo><mo separator="true">,</mo><mi>s</mi><mi>t</mi><mi>r</mi><mi>i</mi><mi>n</mi><mi>g</mi></mrow><annotation encoding="application/x-tex">middleware[, string </annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal">mi</span><span class="mord mathnormal">dd</span><span class="mord mathnormal" style="margin-right:0.01968em;">l</span><span class="mord mathnormal">e</span><span class="mord mathnormal" style="margin-right:0.02691em;">w</span><span class="mord mathnormal">a</span><span class="mord mathnormal">re</span><span class="mopen">[</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">s</span><span class="mord mathnormal">t</span><span class="mord mathnormal" style="margin-right:0.02778em;">r</span><span class="mord mathnormal">in</span><span class="mord mathnormal" style="margin-right:0.03588em;">g</span></span></span></span>name = null ]) : mixed

Parameters

$middleware : callable

Middleware function to add.

$name : string = null

Name of the middleware.

appendBuild()

Append a middleware to the build step.

public appendBuild(callable <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>m</mi><mi>i</mi><mi>d</mi><mi>d</mi><mi>l</mi><mi>e</mi><mi>w</mi><mi>a</mi><mi>r</mi><mi>e</mi><mo stretchy="false">[</mo><mo separator="true">,</mo><mi>s</mi><mi>t</mi><mi>r</mi><mi>i</mi><mi>n</mi><mi>g</mi></mrow><annotation encoding="application/x-tex">middleware[, string </annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal">mi</span><span class="mord mathnormal">dd</span><span class="mord mathnormal" style="margin-right:0.01968em;">l</span><span class="mord mathnormal">e</span><span class="mord mathnormal" style="margin-right:0.02691em;">w</span><span class="mord mathnormal">a</span><span class="mord mathnormal">re</span><span class="mopen">[</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">s</span><span class="mord mathnormal">t</span><span class="mord mathnormal" style="margin-right:0.02778em;">r</span><span class="mord mathnormal">in</span><span class="mord mathnormal" style="margin-right:0.03588em;">g</span></span></span></span>name = null ]) : mixed

Parameters

$middleware : callable

Middleware function to add.

$name : string = null

Name of the middleware.

appendInit()

Append a middleware to the init step.

public appendInit(callable <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>m</mi><mi>i</mi><mi>d</mi><mi>d</mi><mi>l</mi><mi>e</mi><mi>w</mi><mi>a</mi><mi>r</mi><mi>e</mi><mo stretchy="false">[</mo><mo separator="true">,</mo><mi>s</mi><mi>t</mi><mi>r</mi><mi>i</mi><mi>n</mi><mi>g</mi></mrow><annotation encoding="application/x-tex">middleware[, string </annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal">mi</span><span class="mord mathnormal">dd</span><span class="mord mathnormal" style="margin-right:0.01968em;">l</span><span class="mord mathnormal">e</span><span class="mord mathnormal" style="margin-right:0.02691em;">w</span><span class="mord mathnormal">a</span><span class="mord mathnormal">re</span><span class="mopen">[</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">s</span><span class="mord mathnormal">t</span><span class="mord mathnormal" style="margin-right:0.02778em;">r</span><span class="mord mathnormal">in</span><span class="mord mathnormal" style="margin-right:0.03588em;">g</span></span></span></span>name = null ]) : mixed

Parameters

$middleware : callable

Middleware function to add.

$name : string = null

Name of the middleware.

appendSign()

Append a middleware to the sign step.

public appendSign(callable <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>m</mi><mi>i</mi><mi>d</mi><mi>d</mi><mi>l</mi><mi>e</mi><mi>w</mi><mi>a</mi><mi>r</mi><mi>e</mi><mo stretchy="false">[</mo><mo separator="true">,</mo><mi>s</mi><mi>t</mi><mi>r</mi><mi>i</mi><mi>n</mi><mi>g</mi></mrow><annotation encoding="application/x-tex">middleware[, string </annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal">mi</span><span class="mord mathnormal">dd</span><span class="mord mathnormal" style="margin-right:0.01968em;">l</span><span class="mord mathnormal">e</span><span class="mord mathnormal" style="margin-right:0.02691em;">w</span><span class="mord mathnormal">a</span><span class="mord mathnormal">re</span><span class="mopen">[</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">s</span><span class="mord mathnormal">t</span><span class="mord mathnormal" style="margin-right:0.02778em;">r</span><span class="mord mathnormal">in</span><span class="mord mathnormal" style="margin-right:0.03588em;">g</span></span></span></span>name = null ]) : mixed

Parameters

$middleware : callable

Middleware function to add.

$name : string = null

Name of the middleware.

appendValidate()

Append a middleware to the validate step.

public appendValidate(callable <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>m</mi><mi>i</mi><mi>d</mi><mi>d</mi><mi>l</mi><mi>e</mi><mi>w</mi><mi>a</mi><mi>r</mi><mi>e</mi><mo stretchy="false">[</mo><mo separator="true">,</mo><mi>s</mi><mi>t</mi><mi>r</mi><mi>i</mi><mi>n</mi><mi>g</mi></mrow><annotation encoding="application/x-tex">middleware[, string </annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal">mi</span><span class="mord mathnormal">dd</span><span class="mord mathnormal" style="margin-right:0.01968em;">l</span><span class="mord mathnormal">e</span><span class="mord mathnormal" style="margin-right:0.02691em;">w</span><span class="mord mathnormal">a</span><span class="mord mathnormal">re</span><span class="mopen">[</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">s</span><span class="mord mathnormal">t</span><span class="mord mathnormal" style="margin-right:0.02778em;">r</span><span class="mord mathnormal">in</span><span class="mord mathnormal" style="margin-right:0.03588em;">g</span></span></span></span>name = null ]) : mixed

Parameters

$middleware : callable

Middleware function to add.

$name : string = null

Name of the middleware.

before()

Add a middleware before the given middleware by name.

public before(string|callable <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>f</mi><mi>i</mi><mi>n</mi><mi>d</mi><mi>N</mi><mi>a</mi><mi>m</mi><mi>e</mi><mo separator="true">,</mo><mi>s</mi><mi>t</mi><mi>r</mi><mi>i</mi><mi>n</mi><mi>g</mi></mrow><annotation encoding="application/x-tex">findName, string </annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal" style="margin-right:0.10764em;">f</span><span class="mord mathnormal">in</span><span class="mord mathnormal">d</span><span class="mord mathnormal" style="margin-right:0.10903em;">N</span><span class="mord mathnormal">am</span><span class="mord mathnormal">e</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">s</span><span class="mord mathnormal">t</span><span class="mord mathnormal" style="margin-right:0.02778em;">r</span><span class="mord mathnormal">in</span><span class="mord mathnormal" style="margin-right:0.03588em;">g</span></span></span></span>withName, callable $middleware) : mixed

Parameters

$findName : string|callable

Add before this

$withName : string

Optional name to give the middleware

$middleware : callable

Middleware to add.

count()

public count() : int

Return values

int

hasHandler()

Returns true if the builder has a handler.

public hasHandler() : bool

Return values

bool

hasMiddleware()

Checks if a middleware exists. The middleware should have been added with a name in order to use this method.

public hasMiddleware(string $name) : bool

Parameters

$name : string

Return values

bool

interpose()

Interpose a function between each middleware (e.g., allowing for a trace through the middleware layers).

public interpose([callable|null $fn = null ]) : mixed

The interpose function is a function that accepts a "step" argument as a string and a "name" argument string. This function must then return a function that accepts the next handler in the list. This function must then return a function that accepts a CommandInterface and optional RequestInterface and returns a promise that is fulfilled with an Aws\ResultInterface or rejected with an Aws\Exception\AwsException object.

Parameters

$fn : callable|null = null

Pass null to remove any previously set function

prependAttempt()

Prepend a middleware to the attempt step.

public prependAttempt(callable <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>m</mi><mi>i</mi><mi>d</mi><mi>d</mi><mi>l</mi><mi>e</mi><mi>w</mi><mi>a</mi><mi>r</mi><mi>e</mi><mo stretchy="false">[</mo><mo separator="true">,</mo><mi>s</mi><mi>t</mi><mi>r</mi><mi>i</mi><mi>n</mi><mi>g</mi></mrow><annotation encoding="application/x-tex">middleware[, string </annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal">mi</span><span class="mord mathnormal">dd</span><span class="mord mathnormal" style="margin-right:0.01968em;">l</span><span class="mord mathnormal">e</span><span class="mord mathnormal" style="margin-right:0.02691em;">w</span><span class="mord mathnormal">a</span><span class="mord mathnormal">re</span><span class="mopen">[</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">s</span><span class="mord mathnormal">t</span><span class="mord mathnormal" style="margin-right:0.02778em;">r</span><span class="mord mathnormal">in</span><span class="mord mathnormal" style="margin-right:0.03588em;">g</span></span></span></span>name = null ]) : mixed

Parameters

$middleware : callable

Middleware function to add.

$name : string = null

Name of the middleware.

prependBuild()

Prepend a middleware to the build step.

public prependBuild(callable <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>m</mi><mi>i</mi><mi>d</mi><mi>d</mi><mi>l</mi><mi>e</mi><mi>w</mi><mi>a</mi><mi>r</mi><mi>e</mi><mo stretchy="false">[</mo><mo separator="true">,</mo><mi>s</mi><mi>t</mi><mi>r</mi><mi>i</mi><mi>n</mi><mi>g</mi></mrow><annotation encoding="application/x-tex">middleware[, string </annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal">mi</span><span class="mord mathnormal">dd</span><span class="mord mathnormal" style="margin-right:0.01968em;">l</span><span class="mord mathnormal">e</span><span class="mord mathnormal" style="margin-right:0.02691em;">w</span><span class="mord mathnormal">a</span><span class="mord mathnormal">re</span><span class="mopen">[</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">s</span><span class="mord mathnormal">t</span><span class="mord mathnormal" style="margin-right:0.02778em;">r</span><span class="mord mathnormal">in</span><span class="mord mathnormal" style="margin-right:0.03588em;">g</span></span></span></span>name = null ]) : mixed

Parameters

$middleware : callable

Middleware function to add.

$name : string = null

Name of the middleware.

prependInit()

Prepend a middleware to the init step.

public prependInit(callable <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>m</mi><mi>i</mi><mi>d</mi><mi>d</mi><mi>l</mi><mi>e</mi><mi>w</mi><mi>a</mi><mi>r</mi><mi>e</mi><mo stretchy="false">[</mo><mo separator="true">,</mo><mi>s</mi><mi>t</mi><mi>r</mi><mi>i</mi><mi>n</mi><mi>g</mi></mrow><annotation encoding="application/x-tex">middleware[, string </annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal">mi</span><span class="mord mathnormal">dd</span><span class="mord mathnormal" style="margin-right:0.01968em;">l</span><span class="mord mathnormal">e</span><span class="mord mathnormal" style="margin-right:0.02691em;">w</span><span class="mord mathnormal">a</span><span class="mord mathnormal">re</span><span class="mopen">[</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">s</span><span class="mord mathnormal">t</span><span class="mord mathnormal" style="margin-right:0.02778em;">r</span><span class="mord mathnormal">in</span><span class="mord mathnormal" style="margin-right:0.03588em;">g</span></span></span></span>name = null ]) : mixed

Parameters

$middleware : callable

Middleware function to add.

$name : string = null

Name of the middleware.

prependSign()

Prepend a middleware to the sign step.

public prependSign(callable <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>m</mi><mi>i</mi><mi>d</mi><mi>d</mi><mi>l</mi><mi>e</mi><mi>w</mi><mi>a</mi><mi>r</mi><mi>e</mi><mo stretchy="false">[</mo><mo separator="true">,</mo><mi>s</mi><mi>t</mi><mi>r</mi><mi>i</mi><mi>n</mi><mi>g</mi></mrow><annotation encoding="application/x-tex">middleware[, string </annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal">mi</span><span class="mord mathnormal">dd</span><span class="mord mathnormal" style="margin-right:0.01968em;">l</span><span class="mord mathnormal">e</span><span class="mord mathnormal" style="margin-right:0.02691em;">w</span><span class="mord mathnormal">a</span><span class="mord mathnormal">re</span><span class="mopen">[</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">s</span><span class="mord mathnormal">t</span><span class="mord mathnormal" style="margin-right:0.02778em;">r</span><span class="mord mathnormal">in</span><span class="mord mathnormal" style="margin-right:0.03588em;">g</span></span></span></span>name = null ]) : mixed

Parameters

$middleware : callable

Middleware function to add.

$name : string = null

Name of the middleware.

prependValidate()

Prepend a middleware to the validate step.

public prependValidate(callable <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>m</mi><mi>i</mi><mi>d</mi><mi>d</mi><mi>l</mi><mi>e</mi><mi>w</mi><mi>a</mi><mi>r</mi><mi>e</mi><mo stretchy="false">[</mo><mo separator="true">,</mo><mi>s</mi><mi>t</mi><mi>r</mi><mi>i</mi><mi>n</mi><mi>g</mi></mrow><annotation encoding="application/x-tex">middleware[, string </annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal">mi</span><span class="mord mathnormal">dd</span><span class="mord mathnormal" style="margin-right:0.01968em;">l</span><span class="mord mathnormal">e</span><span class="mord mathnormal" style="margin-right:0.02691em;">w</span><span class="mord mathnormal">a</span><span class="mord mathnormal">re</span><span class="mopen">[</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord mathnormal">s</span><span class="mord mathnormal">t</span><span class="mord mathnormal" style="margin-right:0.02778em;">r</span><span class="mord mathnormal">in</span><span class="mord mathnormal" style="margin-right:0.03588em;">g</span></span></span></span>name = null ]) : mixed

Parameters

$middleware : callable

Middleware function to add.

$name : string = null

Name of the middleware.

remove()

Remove a middleware by name or by instance from the list.

public remove(string|callable $nameOrInstance) : mixed

Parameters

$nameOrInstance : string|callable

Middleware to remove.

resolve()

Compose the middleware and handler into a single callable function.

public resolve() : callable

Return values

callable

setHandler()

Set the HTTP handler that actually returns a response.

public setHandler(callable $handler) : mixed

Parameters

$handler : callable

Function that accepts a request and array of options and returns a Promise.