3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
13 use Civi\Api4\Action\Queue\ClaimItems
;
14 use Civi\Api4\Action\Queue\RunItems
;
17 * Track a list of durable/scannable queues.
19 * Registering a queue in this table (and setting `is_auto=1`) can
20 * allow it to execute tasks automatically in the background.
26 class Queue
extends \Civi\Api4\Generic\DAOEntity
{
28 use Generic\Traits\ManagedEntity
;
33 public static function permissions() {
35 'meta' => ['access CiviCRM'],
36 'default' => ['administer queues'],
37 'get' => ['access CiviCRM'],
38 'runItem' => [\CRM_Core_Permission
::ALWAYS_DENY_PERMISSION
],
43 * Claim an item from the queue. Returns zero or one items.
45 * Note: This is appropriate for persistent, auto-run queues.
47 * @param bool $checkPermissions
48 * @return \Civi\Api4\Action\Queue\ClaimItems
50 public static function claimItems($checkPermissions = TRUE) {
51 return (new ClaimItems(static::getEntityName(), __FUNCTION__
))
52 ->setCheckPermissions($checkPermissions);
56 * Run an item from the queue.
58 * Note: This is appropriate for persistent, auto-run queues.
60 * @param bool $checkPermissions
61 * @return \Civi\Api4\Action\Queue\RunItems
63 public static function runItems($checkPermissions = TRUE) {
64 return (new RunItems(static::getEntityName(), __FUNCTION__
))
65 ->setCheckPermissions($checkPermissions);