vendredi 30 mars 2018

Laravel 5.5 - Horizon custom job tags for queued event listener

In the documentation for Horizon, it mentions that custom tags can be added to queued event listeners. However, I can't find any way to pull in my event instance containing the data I need. The example given uses type-hinting to pull the relevant model out of the service container and assigns it to an instance variable in the constructor, then uses that instance variable in the tags() method to get data about the particular model instance being operated on.

When doing this in a queued event listener though, it doesn't work. In fact, the constructor doesn't ever seem to be called at all, due to the model being serialized and 're-hydrated' when it comes to be executed. So type-hinting in the constructor does nothing, and tags() appears to be called before handle(), so I can't get access to the event object I'm listening to.

Does anyone know how I can get event information in a tag in this situation?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire