class CleanupRevisionsQueueWorker in Node Revisions Autoclean 8
Class NotifyQueueWorker.
Plugin annotation
@QueueWorker(
id = "cleanup_revisions_worker",
title = @Translation("Cleanup revisions"),
cron = {"time" = 120}
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Queue\QueueWorkerBase implements QueueWorkerInterface
- class \Drupal\node_revisions_autoclean\Plugin\QueueWorker\CleanupRevisionsQueueWorker implements ContainerFactoryPluginInterface uses StringTranslationTrait
- class \Drupal\Core\Queue\QueueWorkerBase implements QueueWorkerInterface
Expanded class hierarchy of CleanupRevisionsQueueWorker
File
- src/
Plugin/ QueueWorker/ CleanupRevisionsQueueWorker.php, line 20
Namespace
Drupal\node_revisions_autoclean\Plugin\QueueWorkerView source
class CleanupRevisionsQueueWorker extends QueueWorkerBase implements ContainerFactoryPluginInterface {
use StringTranslationTrait;
/**
* Drupal\node_revisions_autoclean\Services\RevisionsManager.
*
* @var Drupal\node_revisions_autoclean\Services\RevisionsManager
*/
protected $revisionsManager;
/**
* CleanupRevisionsQueueWorker constructor.
*
* @param array $configuration
* Configuration.
* @param string $plugin_id
* Pugin id.
* @param mixed $plugin_definition
* Plugin definition.
* @param Drupal\node_revisions_autoclean\Services\RevisionsManager $revisionsManager
* RevisionsManager.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, RevisionsManager $revisionsManager) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->revisionsManager = $revisionsManager;
}
/**
* Creates an instance of the plugin.
*
* @param \Symfony\Component\DependencyInjection\ContainerInterface $container
* The container to pull out services used in the plugin.
* @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.
*
* @return static
* Returns an instance of this plugin.
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('node_revisions_autoclean.revisions_manager'));
}
/**
* Works on a single queue item.
*
* @param mixed $data
* The data that was passed to
* \Drupal\Core\Queue\QueueInterface::createItem() when the item was queued.
*
* @throws \Drupal\Core\Queue\RequeueException
* Processing is not yet finished. This will allow another process to claim
* the item immediately.
* @throws \Exception
* A QueueWorker plugin may throw an exception to indicate there was a
* problem. The cron process will log the exception, and leave the item in
* the queue to be processed again later.
* @throws \Drupal\Core\Queue\SuspendQueueException
* More specifically, a SuspendQueueException should be thrown when a
* QueueWorker plugin is aware that the problem will affect all subsequent
* workers of its queue. For example, a callback that makes HTTP requests
* may find that the remote server is not responding. The cron process will
* behave as with a normal Exception, and in addition will not attempt to
* process further items from the current item's queue during the current
* cron run.
*
* @see \Drupal\Core\Cron::processQueues()
*/
public function processItem($data) {
$revisions = $this->revisionsManager
->revisionsToDelete($data->node);
\Drupal::logger('node_revisions_autoclean')
->info($this
->t("Deleting @count old(s) revision(s) for node @nid : @label", [
'@count' => count($revisions),
'@nid' => $data->node
->id(),
'@label' => $data->node
->label(),
]));
$this->revisionsManager
->deleteRevisions($revisions);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CleanupRevisionsQueueWorker:: |
protected | property | Drupal\node_revisions_autoclean\Services\RevisionsManager. | |
CleanupRevisionsQueueWorker:: |
public static | function |
Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface:: |
|
CleanupRevisionsQueueWorker:: |
public | function |
Works on a single queue item. Overrides QueueWorkerInterface:: |
|
CleanupRevisionsQueueWorker:: |
public | function |
CleanupRevisionsQueueWorker constructor. Overrides PluginBase:: |
|
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. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |