X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;ds=sidebyside;f=Civi.php;h=3c9d71f929859835f0d6b1f0d94552c240d5d84a;hb=af38636c1b726f2c3b0e4aa14d9b400aab820036;hp=9e4b8dcbfd764a9e0243b80c7a0e54484d88ca19;hpb=31f306c24c4673a5e3b73d13b60f79d5da208afb;p=civicrm-core.git diff --git a/Civi.php b/Civi.php index 9e4b8dcbfd..3c9d71f929 100644 --- a/Civi.php +++ b/Civi.php @@ -105,6 +105,29 @@ class Civi { return \Civi\Core\Container::getBootService('paths'); } + /** + * Fetch a queue object. + * + * Note: Historically, `CRM_Queue_Queue` objects were not persistently-registered. Persistence + * is now encouraged. This facade has a bias towards persistently-registered queues. + * + * @param string $name + * The name of a persistent/registered queue (stored in `civicrm_queue`) + * @param array{type: string, is_autorun: bool, reset: bool, is_persistent: bool} $params + * Specification for a queue. + * This is not required for accessing an existing queue. + * Specify this if you wish to auto-create the queue or to include advanced options (eg `reset`). + * Example: ['type' => 'SqlParallel'] + * Defaults: ['reset'=>FALSE, 'is_persistent'=>TRUE, 'is_autorun'=>FALSE] + * @return \CRM_Queue_Queue + * @see \CRM_Queue_Service + */ + public static function queue(string $name, array $params = []): CRM_Queue_Queue { + $defaults = ['reset' => FALSE, 'is_persistent' => TRUE]; + $params = array_merge($defaults, $params, ['name' => $name]); + return CRM_Queue_Service::singleton()->create($params); + } + /** * Obtain the formatting object. *