protected function Cron::enqueueSubscriptions in Commerce Recurring Framework 8
Enqueues pending and trial subscriptions for activation.
Parameters
\Drupal\advancedqueue\Entity\QueueInterface $recurring_queue: The recurring queue.
File
- src/
Cron.php, line 127
Class
- Cron
- Default cron implementation.
Namespace
Drupal\commerce_recurringCode
protected function enqueueSubscriptions(QueueInterface $recurring_queue) {
$subscription_storage = $this->entityTypeManager
->getStorage('commerce_subscription');
$subscription_ids = $subscription_storage
->getQuery()
->condition('state', [
'pending',
'trial',
], 'IN')
->condition('starts', $this->time
->getRequestTime(), '<=')
->accessCheck(FALSE)
->execute();
if (!$subscription_ids) {
return;
}
foreach ($subscription_ids as $subscription_id) {
$activate_job = Job::create('commerce_subscription_activate', [
'subscription_id' => $subscription_id,
]);
$recurring_queue
->enqueueJob($activate_job);
}
}