ResourceIterator
extends AbstractHasDispatcher
in package
implements
ResourceIteratorInterface
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
$command
protected
CommandInterface
$command
Command used to send requests
$data
protected
array<string|int, mixed>
$data
= array()
Initial data passed to the constructor
$eventDispatcher
protected
EventDispatcherInterface
$eventDispatcher
$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
$originalCommand
protected
CommandInterface
$originalCommand
First sent command
$pageSize
protected
int
$pageSize
Maximum number of resources to fetch per request
$requestCount
protected
int
$requestCount
= 0
Number of requests sent
$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
addSubscriber()
Add an event subscriber to the dispatcher
public
addSubscriber(EventSubscriberInterface $subscriber) : self
Parameters
- $subscriber : EventSubscriberInterface
-
Event subscriber
Return values
selfcount()
public
count() : mixed
current()
public
current() : mixed
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>getEventDispatcher()
Get the EventDispatcher of the request
public
getEventDispatcher() : EventDispatcherInterface
Return values
EventDispatcherInterfacegetNextToken()
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
intkey()
public
key() : mixed
next()
public
next() : mixed
rewind()
Rewind the Iterator to the first element and send the original command
public
rewind() : mixed
set()
Set an option on the iterator
public
set(string $key, mixed $value) : ResourceIterator
Parameters
- $key : string
-
Key of the option to set
- $value : mixed
-
Value to set for the option
Return values
ResourceIteratorsetEventDispatcher()
Set the EventDispatcher of the request
public
setEventDispatcher(EventDispatcherInterface $eventDispatcher) : self
Parameters
- $eventDispatcher : EventDispatcherInterface
Return values
selfsetLimit()
Attempt to limit the total number of resources returned by the iterator.
public
setLimit(mixed $limit) : ResourceIteratorInterface
You may still receive more items than you specify. Set to 0 to specify no limit.
Parameters
- $limit : mixed
-
Limit amount
Return values
ResourceIteratorInterfacesetPageSize()
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
ResourceIteratorInterfacetoArray()
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>valid()
public
valid() : 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