interface Listable

Represents a resource that can be enumerated (listed over).

Methods

enumerate (array $def, array $userVals = array(), callable $mapFn = null)

This method iterates over a collection of resources. It sends the operation's request to the API, parses the response, converts each element into {see self} and - if pagination is supported - continues to send requests until an empty collection is received back.

Details

enumerate(array $def, array $userVals = array(), callable $mapFn = null)

This method iterates over a collection of resources. It sends the operation's request to the API, parses the response, converts each element into {see self} and - if pagination is supported - continues to send requests until an empty collection is received back.

For paginated collections, it sends subsequent requests according to a marker URL query. The value of the marker will depend on the last element returned in the previous response. If a limit is provided, the loop will continue up until that point.

Parameters

$def array The operation definition
$userVals array The user values
$mapFn callable An optional callback that will be executed on every resource iteration.

Example code

$listable->enumerate($def, $userVals, $mapFn);