class QueueWorker extends Plugin (View source)

Declare a worker class for processing a queue item.

Worker plugins are used by some queues for processing the individual items in the queue. In that case, the ID of the worker plugin needs to match the machine name of a queue, so that you can retrieve the queue back end by calling \Drupal\Core\Queue\QueueFactory::get($plugin_id).

\Drupal\Core\Cron::processQueues() processes queues that use workers; they can also be processed outside of the cron process.

Some queues do not use worker plugins: you can create queues, add items to them, claim them, etc. without using a QueueWorker plugin. However, you will need to take care of processing the items in the queue in that case. You can look at \Drupal\Core\Cron::processQueues() for an example of how to process a queue that uses workers, and adapt it to your queue.

Plugin Namespace: Plugin\QueueWorker

For a working example, see \Drupal\aggregator\Plugin\QueueWorker\AggregatorRefresh.

Properties

protected array $definition

The plugin definition read from the class annotation.

from  Plugin
string $id

The plugin ID.

Translation $title

The human-readable title of the plugin.

array $cron

An associative array containing an optional key.

Methods

__construct($values)

Constructs a Plugin object.

from  Plugin
array
parse(array $values)

Parses an annotation into its definition.

from  Plugin
get()

Gets the value of an annotation.

from  Plugin
string
getProvider()

Gets the name of the provider of the annotated class.

from  Plugin
setProvider(string $provider)

Sets the name of the provider of the annotated class.

from  Plugin
string
getId()

Gets the unique ID for this annotated class.

from  Plugin
string
getClass()

Gets the class of the annotated class.

from  Plugin
setClass(string $class)

Sets the class of the annotated class.

from  Plugin

Details

__construct($values)

Constructs a Plugin object.

Builds up the plugin definition and invokes the get() method for any classed annotations that were used.

Parameters

$values

protected array parse(array $values)

Parses an annotation into its definition.

Parameters

array $values

The annotation array.

Return Value

array

The parsed annotation as a definition.

get()

Gets the value of an annotation.

string getProvider()

Gets the name of the provider of the annotated class.

Return Value

string

setProvider(string $provider)

Sets the name of the provider of the annotated class.

Parameters

string $provider

The provider of the annotated class.

string getId()

Gets the unique ID for this annotated class.

Return Value

string

string getClass()

Gets the class of the annotated class.

Return Value

string

setClass(string $class)

Sets the class of the annotated class.

Parameters

string $class

The class of the annotated class.