Documentation

Manager
in package
Uses TEventDispatcher

Manages the job queue.

Table of Contents

Properties

$instance  : Manager|null
The instance of the Manager class.
$_config  : array<string|int, mixed>
Array containing configuration settings.
$_driver  : string
The driver used for accessing the queue.
$_storages  : array<string|int, mixed>
Array containing storage settings.

Methods

__construct()  : mixed
Constructor for the Manager class.
AddJob()  : bool
Adds a job to the queue.
Create()  : self
Creates an instance of the Manager class.
Dashboard()  : array<string|int, mixed>
Retrieves dashboard data including active, error, and success jobs.
DeleteJob()  : bool
Deletes a job from the queue.
DispatchEvent()  : object|null
Dispatches an event.
FailJob()  : bool
Marks a job as failed in the queue.
GetJobById()  : IJob|null
Retrieves a job from the queue by its ID.
GetNextJob()  : IJob|null
Retrieves the next job from the specified queue.
HandleEvent()  : self
Adds an event handler.
JobIsRunning()  : bool
Checks the job exists and is running
Migrate()  : bool
Migrates the job queue.
ProcessJobs()  : never
Processes jobs from the specified queue indefinitely.
RemoveHandler()  : self
Removes an event handler.
SuccessJob()  : bool
Marks a job as successfully completed in the queue.
UpdateJob()  : bool
Updates a job in the queue.

Properties

$instance

The instance of the Manager class.

public static Manager|null $instance = null

$_config

Array containing configuration settings.

private array<string|int, mixed> $_config = []

$_driver

The driver used for accessing the queue.

private string $_driver = ''

$_storages

Array containing storage settings.

private array<string|int, mixed> $_storages = []

Methods

__construct()

Constructor for the Manager class.

public __construct() : mixed

AddJob()

Adds a job to the queue.

public AddJob(IJob $job[, string|null $startDate = null ]) : bool
Parameters
$job : IJob

The job to add.

$startDate : string|null = null

The start date of the job.

Tags
throws
Exception

If the job already exists.

Return values
bool

True if the job is added successfully, false otherwise.

Create()

Creates an instance of the Manager class.

public static Create() : self
Return values
self

The created instance of the Manager class.

Dashboard()

Retrieves dashboard data including active, error, and success jobs.

public Dashboard() : array<string|int, mixed>
Return values
array<string|int, mixed>

An array containing dashboard data.

DeleteJob()

Deletes a job from the queue.

public DeleteJob(IJob $job) : bool
Parameters
$job : IJob

The job to delete.

Tags
throws
Exception

If the job does not exist.

Return values
bool

True if the job is deleted successfully, false otherwise.

DispatchEvent()

Dispatches an event.

public DispatchEvent(string|Event $event[, mixed $args = null ][, bool $async = false ]) : object|null
Parameters
$event : string|Event

The event object or its name.

$args : mixed = null

Additional arguments to pass to the event handlers.

$async : bool = false

Whether to dispatch the event asynchronously.

Return values
object|null

The event object with updated arguments, or null if the event does not exist.

FailJob()

Marks a job as failed in the queue.

public FailJob(IJob $job, Throwable $e) : bool
Parameters
$job : IJob

The job that failed.

$e : Throwable

The exception that caused the job to fail.

Tags
throws
Exception

If the job does not exist.

Return values
bool

True if the job is marked as failed successfully, false otherwise.

GetJobById()

Retrieves a job from the queue by its ID.

public GetJobById(int $id) : IJob|null
Parameters
$id : int

The ID of the job to retrieve.

Return values
IJob|null

The job if found, or null if no job with the specified ID exists.

GetNextJob()

Retrieves the next job from the specified queue.

public GetNextJob(array<string|int, mixed> $queue) : IJob|null
Parameters
$queue : array<string|int, mixed>

The queue from which to retrieve the next job.

Return values
IJob|null

The next job if available, or null if no jobs are available in the queue.

HandleEvent()

Adds an event handler.

public HandleEvent(array<string|int, mixed>|string $ename, mixed $listener) : self
Parameters
$ename : array<string|int, mixed>|string

The event name or an array of event names.

$listener : mixed

The event handler.

Return values
self

JobIsRunning()

Checks the job exists and is running

public JobIsRunning(string $class, string|null $payloadClass[, array<string|int, mixed>|object|null $payloadFilter = null ]) : bool
Parameters
$class : string

The job class

$payloadClass : string|null

The job payload class

$payloadFilter : array<string|int, mixed>|object|null = null

object of payload to check

Return values
bool

true if the job exists and running, false if job exists and not running, and null if job does not exists

Migrate()

Migrates the job queue.

public Migrate(Logger $logger) : bool
Parameters
$logger : Logger

The logger instance.

Tags
throws
Exception

When tables cannot be created.

Return values
bool

True if migration was successful, false otherwise.

ProcessJobs()

Processes jobs from the specified queue indefinitely.

public ProcessJobs(string $queue) : never
Parameters
$queue : string

The queue to process jobs from.

Tags
suppress

PHP0420

Return values
never

This method never returns.

RemoveHandler()

Removes an event handler.

public RemoveHandler(string $ename, mixed $listener) : self
Parameters
$ename : string

The event name.

$listener : mixed

The event handler to remove.

Return values
self

SuccessJob()

Marks a job as successfully completed in the queue.

public SuccessJob(IJob $job, array<string|int, mixed>|object $result) : bool
Parameters
$job : IJob

The job that was successfully completed.

$result : array<string|int, mixed>|object

The result of the job execution.

Tags
throws
Exception

If the job does not exist.

Return values
bool

True if the job is marked as successfully completed, false otherwise.

UpdateJob()

Updates a job in the queue.

public UpdateJob(IJob $job[, string|null $startDate = null ]) : bool
Parameters
$job : IJob

The job to update.

$startDate : string|null = null

The start date of the job.

Tags
throws
Exception

If the job does not exist.

Return values
bool

True if the job is updated successfully, false otherwise.


        
On this page

Search results