- Issue created by @somebodysysop
- πΊπΈUnited States somebodysysop
I actually figured out some stuff using ChatGPT.
However, I'd like to know how to create a queue programmatically. I created one in the UI. I've been trying to determine from Query.php how to do the same programmatically, but no luck so far.
This is what I have:
// Get the entity type manager service. $entity_type_manager = \Drupal::entityTypeManager(); // Create the queue. $queue = $entity_type_manager->getStorage('advancedqueue_queue')->create([ 'id' => 'batchembed', 'label' => 'BatchEmbed', 'backend' => 'database', 'backend_configuration' => [], 'lease_time' => 300, // 300 seconds 'processor' => 'cron', 'processing_time' => 2700, // 2700 seconds 'remove_finished_jobs' => ADVANCEDQUEUE_REMOVE_FINISHED_JOBS_DAYS, 'remove_finished_jobs_value' => 7, // 7 days 'remove_finished_jobs_state' => ADVANCEDQUEUE_JOB_STATE_SUCCESS, ]); // Save the queue. $queue->save();
What am I missing?
- Status changed to Needs review
over 1 year ago 7:20am 8 July 2023 - π«π·France fgm Paris, France
You were not far, but the options are not exactly those ones, and the constants do not exist, they look like ChatGPT hallucinations:
use Drupal\advancedqueue\Entity\QueueInterface; use Drupal\advancedqueue\Job; $etm = \Drupal::entityTypeManager(); $storage = $etm->getStorage('advancedqueue_queue'); $q = $storage->create([ 'id' => 'batchembed', 'label' => 'BatchEmbed', 'backend' => 'database', 'backend_configuration' => ['lease_time' => 300], 'processor' => QueueInterface::PROCESSOR_CRON, 'processing_time' => 2700, 'threshold' => [ 'type' => QueueInterface::QUEUE_THRESHOLD_DAYS, 'limit' => 7, 'state' => Job::STATE_SUCCESS, ], 'locked' => FALSE, ]); $queue->save();
- Status changed to Fixed
over 1 year ago 8:50am 8 July 2023 Automatically closed - issue fixed for 2 weeks with no activity.
- Status changed to Fixed
over 1 year ago 9:25am 22 July 2023