Callback Events
There are four callback events that Haystack provides throughout its lifecycle. These are then, catch, finally and paused. You can use these methods to run application code like notifying a user.
Since these callback events are serialized and stored in the database you cannot use $this inside of the anonymous functions.
Then
The “then” event is triggered when the haystack has been completed successfully.
Catch
The “catch” event is triggered when the haystack has failed. You will still have the failed job to see what the error was, but this is useful if you need to perform any cleanup.
Finally
The “finally “event is always triggered at the end of a haystack on both success and failure.
Paused
The "paused" event is triggered if the Haystack has been paused using the pauseHaystack
method or a job has been released using the longRelease
method. This is useful if you need to update the database to mark an import as paused, especially if the pause is for a long time.
Invokable classes
Each of these methods supports invokable classes. If you use invokable classes you will have access to the $this context.
Chained Methods
Each of the callback events can be chained for multiple events.
Last updated