class Simple in Entityqueue 8
Defines an entity queue handler that manages a single subqueue.
Plugin annotation
@EntityQueueHandler(
id = "simple",
title = @Translation("Simple queue"),
description = @Translation("Provides a queue with a single (fixed) subqueue."),
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\entityqueue\EntityQueueHandlerBase implements EntityQueueHandlerInterface uses DependencySerializationTrait, StringTranslationTrait
- class \Drupal\entityqueue\Plugin\EntityQueueHandler\Simple implements ContainerFactoryPluginInterface uses RedirectDestinationTrait
- class \Drupal\entityqueue\EntityQueueHandlerBase implements EntityQueueHandlerInterface uses DependencySerializationTrait, StringTranslationTrait
Expanded class hierarchy of Simple
File
- src/
Plugin/ EntityQueueHandler/ Simple.php, line 24
Namespace
Drupal\entityqueue\Plugin\EntityQueueHandlerView source
class Simple extends EntityQueueHandlerBase implements ContainerFactoryPluginInterface {
use RedirectDestinationTrait;
/**
* The entity repository.
*
* @var \Drupal\Core\Entity\EntityRepositoryInterface
*/
protected $entityRepository;
/**
* The module handler.
*
* @var \Drupal\Core\Extension\ModuleHandlerInterface
*/
protected $moduleHandler;
/**
* Constructs a Simple queue handler object.
*
* @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\EntityRepositoryInterface $entity_repository
* The entity repository.
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityRepositoryInterface $entity_repository, ModuleHandlerInterface $module_handler) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->entityRepository = $entity_repository;
$this->moduleHandler = $module_handler;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('entity.repository'), $container
->get('module_handler'));
}
/**
* {@inheritdoc}
*/
public function supportsMultipleSubqueues() {
return FALSE;
}
/**
* {@inheritdoc}
*/
public function hasAutomatedSubqueues() {
return TRUE;
}
/**
* {@inheritdoc}
*/
public function getQueueListBuilderOperations() {
// Simple queues have just one subqueue so we can link directly to the edit
// form.
$subqueue = EntitySubqueue::load($this->queue
->id());
$subqueue = $this->entityRepository
->getTranslationFromContext($subqueue);
$operations['edit_subqueue'] = [
'title' => $this
->t('Edit items'),
'weight' => -9,
'url' => $subqueue
->toUrl('edit-form')
->mergeOptions([
'query' => $this
->getRedirectDestination()
->getAsArray(),
]),
];
// Add a 'Translate' operation if translation is enabled for this queue.
if ($this->moduleHandler
->moduleExists('content_translation') && content_translation_translate_access($subqueue)
->isAllowed()) {
$operations['translate_subqueue'] = [
'title' => $this
->t('Translate subqueue'),
'url' => $subqueue
->toUrl('drupal:content-translation-overview'),
'weight' => -8,
];
}
return $operations;
}
/**
* {@inheritdoc}
*/
public function onQueuePostSave(EntityQueueInterface $queue, EntityStorageInterface $storage, $update = TRUE) {
// Make sure that every simple queue has a subqueue.
if ($update) {
$subqueue = EntitySubqueue::load($queue
->id());
$subqueue
->setTitle($queue
->label());
}
else {
$subqueue = EntitySubqueue::create([
'queue' => $queue
->id(),
'name' => $queue
->id(),
'title' => $queue
->label(),
'langcode' => $queue
->language()
->getId(),
]);
}
$subqueue
->save();
}
/**
* {@inheritdoc}
*/
public function onQueuePostDelete(EntityQueueInterface $queue, EntityStorageInterface $storage) {
// Delete the subqueue when the parent queue is deleted.
if ($subqueue = EntitySubqueue::load($queue
->id())) {
$subqueue
->delete();
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
EntityQueueHandlerBase:: |
protected | property | The entity queue that is using this plugin. | |
EntityQueueHandlerBase:: |
public | function |
Form constructor. Overrides PluginFormInterface:: |
2 |
EntityQueueHandlerBase:: |
public | function |
Calculates dependencies for the configured plugin. Overrides DependentPluginInterface:: |
|
EntityQueueHandlerBase:: |
public | function |
Gets default configuration for this plugin. Overrides ConfigurableInterface:: |
2 |
EntityQueueHandlerBase:: |
public | function |
Gets this plugin's configuration. Overrides ConfigurableInterface:: |
|
EntityQueueHandlerBase:: |
public | function |
Acts on loaded entity queues. Overrides EntityQueueHandlerInterface:: |
|
EntityQueueHandlerBase:: |
public | function |
Acts on entity queues before they are deleted and before hooks are invoked. Overrides EntityQueueHandlerInterface:: |
|
EntityQueueHandlerBase:: |
public | function |
Acts on an entity queue before the presave hook is invoked. Overrides EntityQueueHandlerInterface:: |
|
EntityQueueHandlerBase:: |
public | function |
Sets the configuration for this plugin instance. Overrides ConfigurableInterface:: |
|
EntityQueueHandlerBase:: |
public | function |
Sets the entity queue that is using this plugin. Overrides EntityQueueHandlerInterface:: |
|
EntityQueueHandlerBase:: |
public | function |
Form submission handler. Overrides PluginFormInterface:: |
2 |
EntityQueueHandlerBase:: |
public | function |
Form validation handler. Overrides PluginFormInterface:: |
1 |
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. | |
RedirectDestinationTrait:: |
protected | property | The redirect destination service. | 1 |
RedirectDestinationTrait:: |
protected | function | Prepares a 'destination' URL query parameter for use with \Drupal\Core\Url. | |
RedirectDestinationTrait:: |
protected | function | Returns the redirect destination service. | |
RedirectDestinationTrait:: |
public | function | Sets the redirect destination service. | |
Simple:: |
protected | property | The entity repository. | |
Simple:: |
protected | property | The module handler. | |
Simple:: |
public static | function |
Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface:: |
|
Simple:: |
public | function |
Gets this queue handler's list builder operations. Overrides EntityQueueHandlerBase:: |
|
Simple:: |
public | function |
Whether or not the handler contains subqueues with an automated lifecycle. Overrides EntityQueueHandlerInterface:: |
|
Simple:: |
public | function |
Acts on deleted entity queues before the delete hook is invoked. Overrides EntityQueueHandlerBase:: |
|
Simple:: |
public | function |
Acts on an entity queue before the insert or update hook is invoked. Overrides EntityQueueHandlerBase:: |
|
Simple:: |
public | function |
Whether or not the handler supports multiple subqueues. Overrides EntityQueueHandlerInterface:: |
|
Simple:: |
public | function |
Constructs a Simple queue handler object. Overrides EntityQueueHandlerBase:: |
|
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. |