Documentation

ResourceIterator extends AbstractHasDispatcher
in package
implements ResourceIteratorInterface

AbstractYes

Class that holds an event dispatcher

Table of Contents

Interfaces

ResourceIteratorInterface
Iterates over a paginated resource using subsequent requests in order to retrieve the entire matching result set

Properties

$command  : CommandInterface
$data  : array<string|int, mixed>
$eventDispatcher  : EventDispatcherInterface
$invalid  : bool
$iteratedCount  : int
$limit  : int
$nextToken  : string
$originalCommand  : CommandInterface
$pageSize  : int
$requestCount  : int
$resources  : array<string|int, mixed>
$retrievedCount  : int

Methods

__construct()  : mixed
addSubscriber()  : self
Add an event subscriber to the dispatcher
count()  : mixed
current()  : mixed
dispatch()  : Event
Helper to dispatch Guzzle events and set the event name on the event
get()  : mixed|null
Get an option from the iterator
getAllEvents()  : array<string|int, mixed>
Get a list of all of the events emitted from the class
getEventDispatcher()  : EventDispatcherInterface
Get the EventDispatcher of the request
getNextToken()  : string
Retrieve the NextToken that can be used in other iterators.
getRequestCount()  : int
Get the total number of requests sent
key()  : mixed
next()  : mixed
rewind()  : mixed
Rewind the Iterator to the first element and send the original command
set()  : ResourceIterator
Set an option on the iterator
setEventDispatcher()  : self
Set the EventDispatcher of the request
setLimit()  : ResourceIteratorInterface
Attempt to limit the total number of resources returned by the iterator.
setPageSize()  : ResourceIteratorInterface
Attempt to limit the total number of resources retrieved per request by the iterator.
toArray()  : array<string|int, mixed>
Get all of the resources as an array (Warning: this could issue a large number of requests)
valid()  : mixed
calculatePageSize()  : int
Returns the value that should be specified for the page size for a request that will maintain any hard limits, but still honor the specified pageSize if the number of items retrieved + pageSize < hard limit
resetState()  : mixed
Reset the internal state of the iterator without triggering a rewind()
sendRequest()  : array<string|int, mixed>
Send a request to retrieve the next page of results. Hook for subclasses to implement.

Properties

$data

protected array<string|int, mixed> $data = array()

Initial data passed to the constructor

$invalid

protected bool $invalid

Whether or not the current value is known to be invalid

$iteratedCount

protected int $iteratedCount = 0

Total number of resources that have been iterated

$limit

protected int $limit

Maximum number of resources to retrieve in total

$nextToken

protected string $nextToken = false

NextToken/Marker for a subsequent request

$pageSize

protected int $pageSize

Maximum number of resources to fetch per request

$resources

protected array<string|int, mixed> $resources

Currently loaded resources

$retrievedCount

protected int $retrievedCount = 0

Total number of resources that have been retrieved

Methods

__construct()

public __construct(CommandInterface $command[, array<string|int, mixed> $data = array() ]) : mixed
Parameters
$command : CommandInterface

Initial command used for iteration

$data : array<string|int, mixed> = array()

Associative array of additional parameters. You may specify any number of custom options for an iterator. Among these options, you may also specify the following values:

  • limit: Attempt to limit the maximum number of resources to this amount
  • page_size: Attempt to retrieve this number of resources per request

dispatch()

Helper to dispatch Guzzle events and set the event name on the event

public dispatch(mixed $eventName[, array<string|int, mixed> $context = array() ]) : Event
Parameters
$eventName : mixed

Name of the event to dispatch

$context : array<string|int, mixed> = array()

Context of the event

Return values
Event

Returns the created event object

get()

Get an option from the iterator

public get(string $key) : mixed|null
Parameters
$key : string

Key of the option to retrieve

Return values
mixed|null

Returns NULL if not set or the value if set

getAllEvents()

Get a list of all of the events emitted from the class

public static getAllEvents() : array<string|int, mixed>
Return values
array<string|int, mixed>

getNextToken()

Retrieve the NextToken that can be used in other iterators.

public getNextToken() : string
Return values
string

Returns a NextToken

getRequestCount()

Get the total number of requests sent

public getRequestCount() : int
Return values
int

rewind()

Rewind the Iterator to the first element and send the original command

public rewind() : mixed

setPageSize()

Attempt to limit the total number of resources retrieved per request by the iterator.

public setPageSize(mixed $pageSize) : ResourceIteratorInterface

The iterator may return more than you specify in the page size argument depending on the service and underlying command implementation. Set to 0 to specify no page size limitation.

Parameters
$pageSize : mixed

Limit amount

Return values
ResourceIteratorInterface

toArray()

Get all of the resources as an array (Warning: this could issue a large number of requests)

public toArray() : array<string|int, mixed>
Return values
array<string|int, mixed>

calculatePageSize()

Returns the value that should be specified for the page size for a request that will maintain any hard limits, but still honor the specified pageSize if the number of items retrieved + pageSize < hard limit

protected calculatePageSize() : int
Return values
int

Returns the page size of the next request.

resetState()

Reset the internal state of the iterator without triggering a rewind()

protected resetState() : mixed

sendRequest()

Send a request to retrieve the next page of results. Hook for subclasses to implement.

protected abstract sendRequest() : array<string|int, mixed>
Return values
array<string|int, mixed>

Returns the newly loaded resources


        
On this page

Search results