![]() ![]() This will allow developers to process a queues seamlessly on cron and/or batch operations. ![]() The module also will provide batch processing bindings for queues managed by the module. * Used to grab functionality from the container. This module aims to simplify the processing of Drupal queues by providing a controller API for the processing of complex ones. entityTypeManager = $entity_type_manager ![]() You don't need to worry about removing the item from the queue once finished, this will be done for you. You can then access each property of the object and process the queue item as you need too. But you should bring in the functionality as needed.įinally add a function for processItem, which takes one parameter which is the queue item. In my below example queue worker, I am bringing in the Entity Type Manager and Database Connection functionality into the class via dependency injection. If there are still items to process, then when the cron job runs again, the queue worker will process some more and it will keep doing this until all items have been processed. The full class is below, but I want to first draw attention to an annotation towards the top of the class, this tells Drupal that we are adding a queue worker with the item of custom_queue, the human name of Custom Queue and that on cron, the queue worker should process as many items as it can in 60 seconds. Welcome to the Drupal API Documentation This site is an API reference for Drupal, generated from comments embedded in the source code. In our example, the class would be called CustomQueue.php. Now inside your module, create a src folder with a folder called Plugin inside, then inside that folder create another folder called QueueWorker. Now create a new php file that will contain your queue worker php class. The queue worker generally processes items on cron, but you can use drush to work through the queue items. First of all, what are queue workers, they are designed to work through each item in the queue that the worker is assigned to and applies the supplied logic to each item as needed. The Queue API in Drupal is designed to manage tasks.The queue system allows placing items in a queue and processing them later.The Queue API is a simple,reliable way to keep track huge lists of tasks without requiring you to know anything about the whole group. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |