Skip to content

DispatchJobTask

Pushes a Job onto QueueManager rather than running it in-process — honors whatever queue driver the app has configured (sync or persistent).

final readonly class DispatchJobTask implements ScheduledTaskAction

ImplementsScheduledTaskAction
SourceDispatchJobTask.php

public function __construct(class-string<Job> $jobClass, array<string, mixed> $params = []): mixed

ParameterTypeDescription
$jobClassclass-string``<Job>
$paramsarray``<``string``, ``mixed``>

Returns mixed

MethodDescription
label(): stringReturns the job’s class name as the task’s label.
run(Container $container): voidPushes the configured job class and parameters onto the queue.

public function label(): string

Returns the job’s class name as the task’s label.

Returns string

public function run(Container $container): void

Pushes the configured job class and parameters onto the queue.

Resolves QueueManager from the container and enqueues the job rather than executing it here, so the app’s queue driver decides whether it runs now or later.

ParameterTypeDescription
$containerContainer