![]() The article also provides a git repo of all sourcecode to download and test locally. An additional form was buit to provide user feedback on queue items left and for a way for the user to manually process the queue. The Drupal 8 Queue API article setup the plugin as an abstract class and extended it to provide both cron as well as manual calls to the plugin. Write the methods for processing queue items and publishing nodes. ![]() ![]() Inject EntityStorageInterface into the plugin (required for publishing nodes).Create the plugin at src/Plugin/QueueWorker which extends QueueWorkerBase and implements the ContainerFactoryPluginInterface.We will be getting more into plugins in Day 8, however for the purpose of using the Queue API in this example, a plugin was created to manage publishing of and processing items in the queue. Use the QueueInterface createItem method to pass in $item.Instantiate a new class stdclass() called $item and pass in the nid from the inserted entity.Get the queue factory service via \Drupal::service(‘queue’) which references the QueueFactory class and then use the get method to create a new queue of type QueueInterface.module file and use hook_entity_insert to grab any newly inserted entities of type node, check publish status, and if unpublished create a queue via the QueueFactory (step). At a high level the following steps outline the process of constructing the module that is documented in this article along with relevant links to the API. After going through the article I gained a better understanding of how the queue system works. Before completing any of the materials, I had no previous experience with the Queue API, nor hook_entity_insert, which was used to create a demo queue system in the referenced article. The main resource for this card is an article called Drupal 8 Queue API – Powerful Manual and Cron Queueing, which I had referenced in an earlier post. Dependency Injection / Service Container Exampleĭay 7 focuses mainly on the Drupal Queue API.Configuring your Local Drupal 8 Development Environment.Attaching JS and CSS Assets in Drupal 8.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |