function activity_creator_empty_queue in Open Social 10.1.x
Same name and namespace in other branches
- 8.9 modules/custom/activity_creator/activity_creator.module \activity_creator_empty_queue()
- 8 modules/custom/activity_creator/activity_creator.module \activity_creator_empty_queue()
- 8.2 modules/custom/activity_creator/activity_creator.module \activity_creator_empty_queue()
- 8.3 modules/custom/activity_creator/activity_creator.module \activity_creator_empty_queue()
- 8.4 modules/custom/activity_creator/activity_creator.module \activity_creator_empty_queue()
- 8.5 modules/custom/activity_creator/activity_creator.module \activity_creator_empty_queue()
- 8.6 modules/custom/activity_creator/activity_creator.module \activity_creator_empty_queue()
- 8.7 modules/custom/activity_creator/activity_creator.module \activity_creator_empty_queue()
- 8.8 modules/custom/activity_creator/activity_creator.module \activity_creator_empty_queue()
- 10.3.x modules/custom/activity_creator/activity_creator.module \activity_creator_empty_queue()
- 10.0.x modules/custom/activity_creator/activity_creator.module \activity_creator_empty_queue()
- 10.2.x modules/custom/activity_creator/activity_creator.module \activity_creator_empty_queue()
Function that empties the activity queues.
1 call to activity_creator_empty_queue()
- activity_creator_cron in modules/
custom/ activity_creator/ activity_creator.module - Implements hook_cron().
File
- modules/
custom/ activity_creator/ activity_creator.module, line 363 - Activity Creator module file.
Code
function activity_creator_empty_queue() {
// Activity queues.
$queues = [
'activity_creator_activities',
'activity_creator_logger',
'activity_logger_message',
'activity_send_email_worker',
];
// The workermanager.
$workerManager = \Drupal::service('plugin.manager.queue_worker');
/** @var Drupal\Core\Queue\QueueFactory $queue */
$queue = \Drupal::service('queue');
for ($i = 0; $i < 5; $i++) {
foreach ($workerManager
->getDefinitions() as $name => $info) {
if (in_array($name, $queues)) {
/** @var Drupal\Core\Queue\QueueInterface $worker */
$worker = $queue
->get($name);
/** @var \Drupal\Core\Queue\QueueWorkerInterface $queue_worker */
$queue_worker = $workerManager
->createInstance($name);
// Must contain items.
if ($worker
->numberOfItems() > 0) {
while ($item = $worker
->claimItem()) {
$queue_worker
->processItem($item->data);
$worker
->deleteItem($item);
}
}
}
}
}
}