Skip to content

Task


Methods

withOptions

Return an instance with configured options.

public withOptions((array|int|string|bool|\Cron\CronExpression|null)[] $options): self

Parameters:

Parameter Type Description
$options (array|int|string|bool|\Cron\CronExpression|null)[]

withScheduler

Return an instance with scheduler.

public withScheduler(\Codefy\Framework\Scheduler\Schedule $schedule): self

Parameters:

Parameter Type Description
$schedule \Codefy\Framework\Scheduler\Schedule

withDispatcher

Return an instance with event dispatcher.

public withDispatcher(\Psr\EventDispatcher\EventDispatcherInterface $dispatcher): self

Parameters:

Parameter Type Description
$dispatcher \Psr\EventDispatcher\EventDispatcherInterface

setUp

Called before a task is executed.

public setUp(): void

execute

Executes a task.

public execute(\Codefy\Framework\Scheduler\Schedule $schedule): void

Parameters:

Parameter Type Description
$schedule \Codefy\Framework\Scheduler\Schedule

tearDown

Called after a task is executed.

public tearDown(): void

Inherited methods

mutexName

Unique name to use for a mutually exclusive lock.

public mutexName(): string

maxRuntime

public maxRuntime(): int

description

Set a command description.

public description(string $description): self

Parameters:

Parameter Type Description
$description string

canRunCommandInBackground

Check if the command can run in background.

public canRunCommandInBackground(): bool

canRunOnlyOneInstance

Check if process con only have one instance.

public canRunOnlyOneInstance(): bool

getExpression

Gets the current cron expression for the task.

public getExpression(): ?string

isDue

Determine if the given command should run based on the Cron expression.

public isDue(string|\DateTimeZone|null $timeZone = null): bool

Parameters:

Parameter Type Description
$timeZone string|\DateTimeZone|null

run

public run(): mixed

getCommand

Returns the command.

public getCommand(): callable|string