From: Tim Otten Date: Tue, 7 Jun 2022 10:25:31 +0000 (-0700) Subject: demoqueue - Include a userjob with the demo X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=56a0eade1148cc5ac45126aaeb1c58eff375e3ac;p=civicrm-core.git demoqueue - Include a userjob with the demo --- diff --git a/tools/extensions/org.civicrm.demoqueue/CRM/Demoqueue/Page/DemoQueue.php b/tools/extensions/org.civicrm.demoqueue/CRM/Demoqueue/Page/DemoQueue.php index a63c4eea01..14e371c795 100644 --- a/tools/extensions/org.civicrm.demoqueue/CRM/Demoqueue/Page/DemoQueue.php +++ b/tools/extensions/org.civicrm.demoqueue/CRM/Demoqueue/Page/DemoQueue.php @@ -6,13 +6,14 @@ require_once 'CRM/Core/Page.php'; * An example page which queues several tasks and then executes them */ class CRM_Demoqueue_Page_DemoQueue extends CRM_Core_Page { - const QUEUE_NAME = 'demo-queue'; function run() { - $queue = CRM_Queue_Service::singleton()->create([ + $queueName = 'demoqueue_' . time(); + + $queue = Civi::queue($queueName, [ 'type' => 'Sql', - 'name' => self::QUEUE_NAME, - 'reset' => TRUE, + 'runner' => 'task', + 'error' => 'abort', ]); for ($i = 0; $i < 5; $i++) { @@ -30,6 +31,12 @@ class CRM_Demoqueue_Page_DemoQueue extends CRM_Core_Page { } } + \Civi\Api4\UserJob::create()->setValues([ + 'type_id:label' => 'Contact Import', + 'status_id:name' => 'in_progress', + 'queue_id.name' => $queue->getName(), + ])->execute(); + $runner = new CRM_Queue_Runner([ 'title' => ts('Demo Queue Runner'), 'queue' => $queue,