3 namespace Drupal\entityqueue\Plugin\EntityQueueHandler;
5 use Drupal\Core\Entity\EntityStorageInterface;
6 use Drupal\Core\Entity\EntityTypeManagerInterface;
7 use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
8 use Drupal\entityqueue\EntityQueueHandlerBase;
9 use Drupal\entityqueue\EntityQueueInterface;
10 use Symfony\Component\DependencyInjection\ContainerInterface;
13 * Defines an entity queue handler that manages multiple subqueues.
15 * @EntityQueueHandler(
17 * title = @Translation("Multiple subqueues")
20 class Multiple extends EntityQueueHandlerBase implements ContainerFactoryPluginInterface {
23 * The entity type manager.
25 * @var \Drupal\Core\Entity\EntityTypeManagerInterface
27 protected $entityTypeManager;
30 * Constructs a Multiple queue handler object.
32 * @param array $configuration
33 * A configuration array containing information about the plugin instance.
34 * @param string $plugin_id
35 * The plugin ID for the plugin instance.
36 * @param mixed $plugin_definition
37 * The plugin implementation definition.
38 * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
39 * The entity type manager.
41 public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager) {
42 parent::__construct($configuration, $plugin_id, $plugin_definition);
44 $this->entityTypeManager = $entity_type_manager;
50 public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
55 $container->get('entity_type.manager')
62 public function supportsMultipleSubqueues() {
69 public function hasAutomatedSubqueues() {
76 public function onQueuePostDelete(EntityQueueInterface $queue, EntityStorageInterface $storage) {
77 // Delete all the subqueues when the parent queue is deleted.
78 $subqueue_storage = $this->entityTypeManager->getStorage('entity_subqueue');
80 $subqueues = $subqueue_storage->loadByProperties([$this->entityTypeManager->getDefinition('entity_subqueue')->getKey('bundle') => $queue->id()]);
81 $subqueue_storage->delete($subqueues);