LoadBalancerIterator
extends PaginatedIterator
in package
Class ResourceIterator is tasked with iterating over resource collections - many of which are paginated. Based on a base URL, the iterator will append elements based on further requests to the API. Each time this happens, query parameters (marker) are updated based on the current value.
Table of Contents
- LIMIT = 'limit'
- MARKER = 'marker'
- $currentMarker : string
- $defaults : array<string|int, mixed>
- $elements : mixed
- $nextUrl : Url
- $options : array<string|int, mixed>
- $position : int
- $required : array<string|int, mixed>
- $resourceParent : object
- $nextElement : mixed
- __construct() : mixed
- append() : mixed
- Appends a value to the container.
- appendElements() : $this
- Append an array of standard objects to the current collection.
- appendNewCollection() : $this|bool
- Retrieve a new page of elements from the API (based on a new request), parse its response, and append them to the collection.
- constructNextUrl() : Url|string
- Make the next page URL.
- constructResource() : mixed
- Using a standard object, this method populates a resource model with all the object data. It does this using a whatever method the parent object has for resource creation.
- count() : int
- current() : mixed
- currentElement() : mixed
- extractNextLink() : bool
- Based on the response body, extract the explicitly set "link" value if provided.
- factory() : mixed
- first() : mixed
- getElement() : mixed
- getOption() : null
- getOptions() : array<string|int, mixed>
- key() : int|mixed
- Return the current position/internal pointer.
- next() : mixed
- Increment the current pointer by 1, and also update the current marker.
- offsetExists() : bool
- Checks to see whether a particular offset key exists.
- offsetGet() : mixed|null
- Get the value for a particular offset key.
- offsetSet() : mixed
- Sets a value to a particular offset.
- offsetUnset() : mixed
- Unset a particular key.
- parseResponseBody() : array<string|int, mixed>
- Based on the response from the API, parse it for the data we need (i.e. an meaningful array of elements).
- populateAll() : mixed
- Walk the entire collection, populating everything.
- rewind() : mixed
- Reset the pointer and current marker.
- search() : mixed
- setBaseUrl() : $this
- setElements() : $this
- setOption() : $this
- Set a particular option.
- setOptions() : $this
- setResourceParent() : $this
- sort() : mixed
- updateMarkerToCurrent() : mixed
- Update the current marker based on the current element. The marker will be based on a particular property of this current element, so you must retrieve it first.
- valid() : bool
- This method is called after self::rewind() and self::next() to check if the current position is valid.
- valueExists() : bool
- Checks to see whether a particular value exists.
- parseOptions() : mixed
- setMarkerFromElement() : mixed
- shouldAppend() : mixed
Constants
LIMIT
public
mixed
LIMIT
= 'limit'
MARKER
public
mixed
MARKER
= 'marker'
Properties
$currentMarker
protected
string
$currentMarker
Used for requests which append elements.
$defaults
protected
array<string|int, mixed>
$defaults
= array('limit.total' => 1000)
Fallback defaults if options are not explicitly set or provided.
$elements
protected
mixed
$elements
$nextUrl
protected
Url
$nextUrl
The next URL for pagination
$options
protected
array<string|int, mixed>
$options
The options for this iterator.
$position
protected
int
$position
Internal pointer of the iterator - reveals its current position.
$required
protected
array<string|int, mixed>
$required
= array()
Required options
$resourceParent
protected
object
$resourceParent
The parent object which resource models are instantiated from. The parent needs to have appropriate methods to instantiate the particular object.
$nextElement
private
mixed
$nextElement
Methods
__construct()
public
__construct([mixed $data = array() ]) : mixed
Parameters
- $data : mixed = array()
Return values
mixed —append()
Appends a value to the container.
public
append( $value) : mixed
Parameters
Return values
mixed —appendElements()
Append an array of standard objects to the current collection.
public
appendElements(array<string|int, mixed> $elements) : $this
Parameters
- $elements : array<string|int, mixed>
Return values
$this —appendNewCollection()
Retrieve a new page of elements from the API (based on a new request), parse its response, and append them to the collection.
public
appendNewCollection() : $this|bool
Return values
$this|bool —constructNextUrl()
Make the next page URL.
public
constructNextUrl() : Url|string
Return values
Url|string —constructResource()
Using a standard object, this method populates a resource model with all the object data. It does this using a whatever method the parent object has for resource creation.
public
constructResource( $object) : mixed
Parameters
Tags
Return values
mixed —count()
public
count() : int
Return values
int —current()
public
current() : mixed
Return values
mixed —currentElement()
public
currentElement() : mixed
Return values
mixed —extractNextLink()
Based on the response body, extract the explicitly set "link" value if provided.
public
extractNextLink( $body) : bool
Parameters
Return values
bool —factory()
public
static factory(mixed $parent[, array<string|int, mixed> $options = array() ][, array<string|int, mixed> $data = array() ]) : mixed
Parameters
- $parent : mixed
- $options : array<string|int, mixed> = array()
- $data : array<string|int, mixed> = array()
Return values
mixed —first()
public
first() : mixed
Tags
Return values
mixed —getElement()
public
getElement(mixed $offset) : mixed
Parameters
- $offset : mixed
Return values
mixed —getOption()
public
getOption( $key) : null
Parameters
Return values
null —getOptions()
public
getOptions() : array<string|int, mixed>
Return values
array<string|int, mixed> —Options for the resource iterator.
key()
Return the current position/internal pointer.
public
key() : int|mixed
Return values
int|mixed —next()
Increment the current pointer by 1, and also update the current marker.
public
next() : mixed
Return values
mixed —offsetExists()
Checks to see whether a particular offset key exists.
public
offsetExists(mixed $offset) : bool
Parameters
- $offset : mixed
Return values
bool —offsetGet()
Get the value for a particular offset key.
public
offsetGet(mixed $offset) : mixed|null
Parameters
- $offset : mixed
Return values
mixed|null —offsetSet()
Sets a value to a particular offset.
public
offsetSet(mixed $offset, mixed $value) : mixed
Parameters
- $offset : mixed
- $value : mixed
Return values
mixed —offsetUnset()
Unset a particular key.
public
offsetUnset(mixed $offset) : mixed
Parameters
- $offset : mixed
Return values
mixed —parseResponseBody()
Based on the response from the API, parse it for the data we need (i.e. an meaningful array of elements).
public
parseResponseBody(mixed $body) : array<string|int, mixed>
Parameters
- $body : mixed
Return values
array<string|int, mixed> —populateAll()
Walk the entire collection, populating everything.
public
populateAll() : mixed
Return values
mixed —rewind()
Reset the pointer and current marker.
public
rewind() : mixed
Return values
mixed —search()
public
search(mixed $callback) : mixed
Parameters
- $callback : mixed
Return values
mixed —setBaseUrl()
public
setBaseUrl(Url $url) : $this
Parameters
- $url : Url
Return values
$this —setElements()
public
setElements([array<string|int, mixed> $data = array() ]) : $this
Parameters
- $data : array<string|int, mixed> = array()
Return values
$this —setOption()
Set a particular option.
public
setOption( $key, $value) : $this
Parameters
Return values
$this —setOptions()
public
setOptions(array<string|int, mixed> $options) : $this
Parameters
- $options : array<string|int, mixed>
Return values
$this —setResourceParent()
public
setResourceParent( $parent) : $this
Parameters
Return values
$this —sort()
public
sort() : mixed
Tags
Return values
mixed —updateMarkerToCurrent()
Update the current marker based on the current element. The marker will be based on a particular property of this current element, so you must retrieve it first.
public
updateMarkerToCurrent() : mixed
Return values
mixed —valid()
This method is called after self::rewind() and self::next() to check if the current position is valid.
public
valid() : bool
Return values
bool —valueExists()
Checks to see whether a particular value exists.
public
valueExists( $value) : bool
Parameters
Return values
bool —parseOptions()
protected
parseOptions(array<string|int, mixed> $options) : mixed
Parameters
- $options : array<string|int, mixed>
Return values
mixed —setMarkerFromElement()
protected
setMarkerFromElement(mixed $element) : mixed
Parameters
- $element : mixed
Return values
mixed —shouldAppend()
protected
shouldAppend() : mixed