class ScheduledTransitionJob in Scheduled Transitions 8
Same name and namespace in other branches
- 2.x src/Plugin/QueueWorker/ScheduledTransitionJob.php \Drupal\scheduled_transitions\Plugin\QueueWorker\ScheduledTransitionJob
Runs a scheduled transition.
Plugin annotation
@QueueWorker(
id = "scheduled_transition_job",
title = @Translation("Scheduled transition job"),
cron = {"time" = 900}
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Queue\QueueWorkerBase implements QueueWorkerInterface
- class \Drupal\scheduled_transitions\Plugin\QueueWorker\ScheduledTransitionJob implements ContainerFactoryPluginInterface
- class \Drupal\Core\Queue\QueueWorkerBase implements QueueWorkerInterface
Expanded class hierarchy of ScheduledTransitionJob
1 file declares its use of ScheduledTransitionJob
File
- src/
Plugin/ QueueWorker/ ScheduledTransitionJob.php, line 23
Namespace
Drupal\scheduled_transitions\Plugin\QueueWorkerView source
class ScheduledTransitionJob extends QueueWorkerBase implements ContainerFactoryPluginInterface {
/**
* The key in data with the ID of a scheduled transition entity to process.
*/
const SCHEDULED_TRANSITION_ID = 'scheduled_transition_id';
/**
* Executes transitions.
*
* @var \Drupal\scheduled_transitions\ScheduledTransitionsRunnerInterface
*/
protected $scheduledTransitionsRunner;
/**
* Storage for scheduled transitions.
*
* @var \Drupal\Core\Entity\EntityStorageInterface
*/
protected $scheduledTransitionStorage;
/**
* Constructs a new ScheduledTransitionJob.
*
* @param array $configuration
* A configuration array containing information about the plugin instance.
* @param string $plugin_id
* The plugin_id for the plugin instance.
* @param mixed $plugin_definition
* The plugin implementation definition.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager
* The entity type manager.
* @param \Drupal\scheduled_transitions\ScheduledTransitionsRunnerInterface $scheduledTransitionsRunner
* Executes transitions.
*/
public function __construct(array $configuration, string $plugin_id, $plugin_definition, EntityTypeManagerInterface $entityTypeManager, ScheduledTransitionsRunnerInterface $scheduledTransitionsRunner) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->scheduledTransitionStorage = $entityTypeManager
->getStorage('scheduled_transition');
$this->scheduledTransitionsRunner = $scheduledTransitionsRunner;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('entity_type.manager'), $container
->get('scheduled_transitions.runner'));
}
/**
* {@inheritdoc}
*/
public function processItem($data) {
$id = $data[static::SCHEDULED_TRANSITION_ID];
$transition = $this->scheduledTransitionStorage
->load($id);
if ($transition) {
try {
$this->scheduledTransitionsRunner
->runTransition($transition);
} catch (ScheduledTransitionMissingEntity $exception) {
$transition
->delete();
}
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
ScheduledTransitionJob:: |
protected | property | Executes transitions. | |
ScheduledTransitionJob:: |
protected | property | Storage for scheduled transitions. | |
ScheduledTransitionJob:: |
public static | function |
Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface:: |
|
ScheduledTransitionJob:: |
public | function |
Works on a single queue item. Overrides QueueWorkerInterface:: |
|
ScheduledTransitionJob:: |
constant | The key in data with the ID of a scheduled transition entity to process. | ||
ScheduledTransitionJob:: |
public | function |
Constructs a new ScheduledTransitionJob. Overrides PluginBase:: |