You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Essentially what I want is a way to mark certain jobs to be picked up by the Job event hooks.
The Jobs that I want to get picked up extend from an Abstract class called AbstractTask. I was hoping since I could perform an instanceof check on the Job like so:
This turned on to not be the case since the job that is actually being referred here it not the actual but a driver specific Job like a syncJob which holds the actual job in its data.
This actually seems to work because the actual job is within the payload -> data -> command
I was hoping since this was Laravel there would be an easier way but checking out the underlying classes that does not seem like the case. Am I missing something here or is there no easier way to actually get the underlying Job which is actually used to initiate this? If there is nothing there I would love to add a method to simplify this process.
Currently I am using these hooks to create status updates for tasks so I know when certain tasks have started, are finished or have failed.
Any thoughts on an easier way to get this done or perhaps this could be an occasion to add an easier way to get this done?
The text was updated successfully, but these errors were encountered:
Not sure if it is easier, but by looking at the code you may not have to deal with the payload directly yourself.
You can try getting the job name from $job there:
$class = $event->job->resolveName();
Once you have the name you can resolve an instance or just check if it inherits from what you want or is of what you want:
// with an instance$instance = app($class);
$instance instanceof AbstractTask// no instanceis_subclass_of($class, AbstractTask::class);
// or to be more inclusive
is_a($class, AbstractTask::class, true);
Heya, thanks for submitting this. This seems like a feature request or an improvement. It's best to post these at the laravel/ideas repository to get support for your idea. After that you may send a PR to the framework. Please only use this issue tracker to report bugs and issues with the framework.
Description:
Essentially what I want is a way to mark certain jobs to be picked up by the Job event hooks.
The Jobs that I want to get picked up extend from an Abstract class called
AbstractTask
. I was hoping since I could perform aninstanceof
check on the Job like so:This turned on to not be the case since the
job
that is actually being referred here it not the actual but a driver specific Job like asyncJob
which holds the actual job in its data.This actually seems to work because the actual job is within the payload -> data -> command
I was hoping since this was Laravel there would be an easier way but checking out the underlying classes that does not seem like the case. Am I missing something here or is there no easier way to actually get the underlying Job which is actually used to initiate this? If there is nothing there I would love to add a method to simplify this process.
Currently I am using these hooks to create status updates for tasks so I know when certain tasks have started, are finished or have failed.
Any thoughts on an easier way to get this done or perhaps this could be an occasion to add an easier way to get this done?
The text was updated successfully, but these errors were encountered: