\Charcoal\QueueAbstractQueueManager

Abstract Queue Manager

The queue manager is used to load queued items and batch-process them.

Loading queued items

If a "queue_id" is specified, only the item for this specific queue will be loaded. Otherwise, all unprocessed queue items will be processed.

Type of queue items

The type of queue items can be set in extended concrete class with the queue_item_proto() method. This method should return a QueueItemInterface instance.

Callbacks

There are 4 available callback methods that can be set:

  • item_callback
    • Called after an item has been processed.
    • Arguments: QueueModelInterface $item
  • item_success_callback
  • item_failure_callback
  • processed_callback
    • Called when the entire queue has been processed
    • Arguments: array $success, array $failures

Summary

Methods
Properties
Constants
__construct()
setData()
setQueueId()
queueId()
setItemCallback()
setItemSuccessCallback()
setItemFailureCallback()
setProcessedCallback()
processQueue()
loadQueueItems()
queueItemProto()
No public properties found
No constants found
setQueueItemFactory()
queueItemFactory()
No protected properties found
N/A
No private methods found
$queueId
$itemCallback
$itemSuccessCallback
$itemFailureCallback
$processedCallback
$queueItemFactory
N/A

Properties

$queueId

$queueId : mixed

The queue ID.

If set, then it will load only the items from this queue. If NULL, load all queued items.

Type

mixed

$itemCallback

$itemCallback : callable

The callback routine when an item is processed (whether resolved or rejected).

Type

callable

$itemSuccessCallback

$itemSuccessCallback : callable

The callback routine when the item is resolved.

Type

callable

$itemFailureCallback

$itemFailureCallback : callable

The callback routine when the item is rejected.

Type

callable

$processedCallback

$processedCallback : callable

The callback routine when the queue is processed.

Type

callable

$queueItemFactory

$queueItemFactory : \Charcoal\Factory\FactoryInterface

Type

\Charcoal\Factory\FactoryInterface

Methods

__construct()

__construct(array  $data = array()) 

Construct new queue manager.

Parameters

array $data

Dependencies and settings.

setData()

setData(array  $data) : \Charcoal\Queue\AbstractQueueManager

Set the manager's data.

Parameters

array $data

The queue data to set.

Returns

\Charcoal\Queue\AbstractQueueManager

Chainable

setQueueId()

setQueueId(mixed  $id) : \Charcoal\Queue\AbstractQueueManager

Set the queue's ID.

Parameters

mixed $id

The unique queue identifier.

Returns

\Charcoal\Queue\AbstractQueueManager

Chainable

queueId()

queueId() : mixed

Get the queue's ID.

Returns

mixed

setItemCallback()

setItemCallback(callable  $callback) : \Charcoal\Queue\QueueManagerInterface

Set the callback routine when an item is processed.

Parameters

callable $callback

A item callback routine.

Returns

\Charcoal\Queue\QueueManagerInterface

Chainable

setItemSuccessCallback()

setItemSuccessCallback(callable  $callback) : \Charcoal\Queue\QueueManagerInterface

Set the callback routine when the item is resolved.

Parameters

callable $callback

A item callback routine.

Returns

\Charcoal\Queue\QueueManagerInterface

Chainable

setItemFailureCallback()

setItemFailureCallback(callable  $callback) : \Charcoal\Queue\QueueManagerInterface

Set the callback routine when the item is rejected.

Parameters

callable $callback

A item callback routine.

Returns

\Charcoal\Queue\QueueManagerInterface

Chainable

setProcessedCallback()

setProcessedCallback(callable  $callback) : \Charcoal\Queue\QueueManagerInterface

Set the callback routine when the queue is processed.

Parameters

callable $callback

A queue callback routine.

Returns

\Charcoal\Queue\QueueManagerInterface

Chainable

processQueue()

processQueue(callable  $callback = null) : boolean

Process the items of the queue.

If no callback is passed and a self::$processedCallback is set, the latter is used.

Parameters

callable $callback

An optional alternative callback routine executed after all queue items are processed.

Returns

boolean —

Success / Failure

loadQueueItems()

loadQueueItems() : \Charcoal\Queue\Collection

Retrieve the items of the current queue.

Returns

\Charcoal\Queue\Collection

setQueueItemFactory()

setQueueItemFactory(\Charcoal\Factory\FactoryInterface  $factory) : \Charcoal\Queue\QueueItemInterface

Parameters

\Charcoal\Factory\FactoryInterface $factory

The factory used to create queue items.

Returns

\Charcoal\Queue\QueueItemInterface

Chainable

queueItemFactory()

queueItemFactory() : \Charcoal\Factory\FactoryInterface

Returns

\Charcoal\Factory\FactoryInterface