ResourceIteratorApplyBatched
extends AbstractHasDispatcher
in package
Apply a callback to the contents of a {@see ResourceIteratorInterface}
Will be removed in a future version and is no longer maintained. Use the Batch\ abstractions instead.
Tags
Table of Contents
Properties
- $batches : int
- $callback : callable|array<string|int, mixed>
- $eventDispatcher : EventDispatcherInterface
- $iterated : int
- $iterator : ResourceIteratorInterface
Methods
- __construct() : mixed
- addSubscriber() : self
- Add an event subscriber to the dispatcher
- apply() : int
- Apply the callback to the contents of the resource iterator
- dispatch() : Event
- Helper to dispatch Guzzle events and set the event name on the event
- getAllEvents() : array<string|int, mixed>
- Get a list of all of the events emitted from the class
- getBatchCount() : int
- Get the total number of batches sent
- getEventDispatcher() : EventDispatcherInterface
- Get the EventDispatcher of the request
- getIteratedCount() : int
- Get the total number of iterated resources
- setEventDispatcher() : self
- Set the EventDispatcher of the request
Properties
$batches
protected
int
$batches
= 0
Total number of sent batches
$callback
protected
callable|array<string|int, mixed>
$callback
$eventDispatcher
protected
EventDispatcherInterface
$eventDispatcher
$iterated
protected
int
$iterated
= 0
Total number of iterated resources
$iterator
protected
ResourceIteratorInterface
$iterator
Methods
__construct()
public
__construct(ResourceIteratorInterface $iterator, array<string|int, mixed>|callable $callback) : mixed
Parameters
- $iterator : ResourceIteratorInterface
-
Resource iterator to apply a callback to
- $callback : array<string|int, mixed>|callable
-
Callback method accepting the resource iterator and an array of the iterator's current resources
addSubscriber()
Add an event subscriber to the dispatcher
public
addSubscriber(EventSubscriberInterface $subscriber) : self
Parameters
- $subscriber : EventSubscriberInterface
-
Event subscriber
Return values
selfapply()
Apply the callback to the contents of the resource iterator
public
apply([int $perBatch = 50 ]) : int
Parameters
- $perBatch : int = 50
-
The number of records to group per batch transfer
Return values
int —Returns the number of iterated resources
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
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>getBatchCount()
Get the total number of batches sent
public
getBatchCount() : int
Return values
intgetEventDispatcher()
Get the EventDispatcher of the request
public
getEventDispatcher() : EventDispatcherInterface
Return values
EventDispatcherInterfacegetIteratedCount()
Get the total number of iterated resources
public
getIteratedCount() : int
Return values
intsetEventDispatcher()
Set the EventDispatcher of the request
public
setEventDispatcher(EventDispatcherInterface $eventDispatcher) : self
Parameters
- $eventDispatcher : EventDispatcherInterface