contacts_events-8.x-1.x-dev/commerce_advancedqueue/commerce_advancedqueue.module
commerce_advancedqueue/commerce_advancedqueue.module
<?php /** * @file * Module file for Commerce Advanced Queue. */ use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Url; /** * Implements hook_entity_operation(). */ function commerce_advancedqueue_entity_operation(EntityInterface $entity) { $operations = []; if ($entity->getEntityTypeId() == 'advancedqueue_queue') { /** @var \Drupal\advancedqueue\Entity\QueueInterface $entity */ if ($entity->getBackendId() == 'database_commerce_order_job') { $operations['jobs'] = [ 'title' => t('List jobs'), 'weight' => -20, 'url' => Url::fromRoute('view.advancedqueue_commerce_order_jobs.page_1', ['arg_0' => $entity->id()]), ]; } } return $operations; } /** * Implements hook_ENTITY_TYPE_storage_load(). */ function commerce_advancedqueue_commerce_order_storage_load(array $entities) { /** @var \Drupal\advancedqueue\Entity\QueueInterface $queue */ $queue = \Drupal::entityTypeManager() ->getStorage('advancedqueue_queue') ->load('commerce_order'); /** @var \Drupal\commerce_advancedqueue\Plugin\AdvancedQueue\Backend\CommerceOrderJobBackendInterface $queue_backend */ $queue_backend = $queue->getBackend(); /** @var \Drupal\advancedqueue\ProcessorInterface $processor */ $processor = \Drupal::service('advancedqueue.processor'); foreach ($entities as $id => $entity) { $job_count = $queue_backend->countJobsForOrder($id); if (empty($job_count['queued'])) { continue; } // If there are jobs to be processed, process them now. while ($job = $queue_backend->claimJobForOrder($id)) { $processor->processJob($job, $queue); } } }