I know how to use ShouldQueue , my question is why it works the way it does.
I need to edit how my new Job is stored in the database, and so I dig the insides of Laravel.
The job I want to change starts from the following event listener:
<?php namespace App\Listeners; use App\Events\NewMail; use Illuminate\Queue\InteractsWithQueue; use Illuminate\Contracts\Queue\ShouldQueue; use App\Jobs\SendEmail; use Carbon\Carbon; class NewMailListener implements ShouldQueue { public function __construct() {
I donβt understand how ShouldQueue magic ShouldQueue , because it does nothing in the source code .
<?php namespace Illuminate\Contracts\Queue; interface ShouldQueue {
I understand that this is a contract , but it does not define anything ... so what does it do exactly? Is there any kind of automatic loading from the namespace?
I was not sure what the interface was, so I looked at it: PHP Docs: Interfaces and left with the impression that even if it is intended for decoupling, and the interface should define something that I do not see in ShouldQueue .
The top comment on this page of PHP docs says the following:
INTERFACE is provided so that you can describe the set of functions and then hide the final implementation of these functions in the implementing class. This allows you to change the IMPLEMENTATION of these functions without changing how you use it.
But where is this function description here?
PS - I know that this interface / contract is used for the queue of the event listener itself, and not for the job that I want to change. But I hope that understanding how the queue interacts with the event listener will better tell me how it works for tasks.
source share