class ScheduledEvent (View source)

Constants

TYPE_COMMAND

Event types

TYPE_TASK

TYPE_EXEC

TYPE_CALL

Properties

protected string $type

The event type

protected mixed $target

The event target (command name, task class, shell command, or closure)

protected array $parameters

The event parameters

protected Schedule $schedule

The schedule instance

protected ?string $mutexName

The unique mutex key for preventing overlaps

protected DateTime $lastRunAt

The last run time

protected bool $running

Whether the event is running

protected ?string $output

The output of the last execution

protected ?int $exitCode

The exit code of the last execution

protected ?callable $beforeCallback

Before callback

protected ?callable $afterCallback

After callback

protected ?callable $failedCallback

Failed callback

protected ?string $connection

The queue connection to use for task execution

Methods

void
__construct(string $type, mixed $target, array $parameters = [])

Create a new scheduled event

getSchedule()

Get the schedule instance

string
getType()

Get the event type

mixed
getTarget()

Get the event target

string
getMutexName()

Get the mutex name for this event

setMutexName(string $name)

Set a custom mutex name

bool
isDue(DateTime|null $currentTime = null)

Check if the event is due to run

void
run()

Run the scheduled event

void
execute()

Execute the event based on its type

void
executeCommand()

Execute a Bow console command

void
executeTask()

Execute a QueueTask

void
pushToQueue(QueueTask $task)

Push the task to a queue connection

onConnection(string $connection)

Set the queue connection to use for task execution

string|null
getConnection()

Get the queue connection

void
executeExec()

Execute a shell command

void
executeCall()

Execute a closure/callback

string
buildBowCommand()

Build a Bow console command

void
runShellCommand(string $command)

Run a shell command

void
runInBackground(string $command)

Run command in background

string
getBowPath()

Get the path to the bow executable

before(callable $callback)

Register a before callback

after(callable $callback)

Register an after callback

onFailure(callable $callback)

Register a failed callback

void
runBeforeCallback()

Execute the before callback

void
runAfterCallback()

Execute the after callback

void
runFailedCallback(Throwable $exception)

Execute the failed callback

DateTime|null
getLastRunAt()

Get the last run time

bool
isRunning()

Check if the event is currently running

string
getCronExpression()

Get the cron expression for this event

string|null
getOutput()

Get the output from the last execution

int|null
getExitCode()

Get the exit code from the last execution

string
getDescription()

Get the event description

Details

void __construct(string $type, mixed $target, array $parameters = [])

Create a new scheduled event

Parameters

string $type
mixed $target
array $parameters

Return Value

void

Schedule getSchedule()

Get the schedule instance

Return Value

Schedule

string getType()

Get the event type

Return Value

string

mixed getTarget()

Get the event target

Return Value

mixed

string getMutexName()

Get the mutex name for this event

Return Value

string

ScheduledEvent setMutexName(string $name)

Set a custom mutex name

Parameters

string $name

Return Value

ScheduledEvent

bool isDue(DateTime|null $currentTime = null)

Check if the event is due to run

Parameters

DateTime|null $currentTime

Return Value

bool

void run()

Run the scheduled event

Return Value

void

Exceptions

SchedulerException

protected void execute()

Execute the event based on its type

Return Value

void

Exceptions

SchedulerException

protected void executeCommand()

Execute a Bow console command

Return Value

void

protected void executeTask()

Execute a QueueTask

Return Value

void

Exceptions

SchedulerException

protected void pushToQueue(QueueTask $task)

Push the task to a queue connection

Parameters

QueueTask $task

Return Value

void

ScheduledEvent onConnection(string $connection)

Set the queue connection to use for task execution

Parameters

string $connection

Return Value

ScheduledEvent

string|null getConnection()

Get the queue connection

Return Value

string|null

protected void executeExec()

Execute a shell command

Return Value

void

protected void executeCall()

Execute a closure/callback

Return Value

void

protected string buildBowCommand()

Build a Bow console command

Return Value

string

protected void runShellCommand(string $command)

Run a shell command

Parameters

string $command

Return Value

void

Exceptions

SchedulerException

protected void runInBackground(string $command)

Run command in background

Parameters

string $command

Return Value

void

protected string getBowPath()

Get the path to the bow executable

Return Value

string

ScheduledEvent before(callable $callback)

Register a before callback

Parameters

callable $callback

Return Value

ScheduledEvent

ScheduledEvent after(callable $callback)

Register an after callback

Parameters

callable $callback

Return Value

ScheduledEvent

ScheduledEvent onFailure(callable $callback)

Register a failed callback

Parameters

callable $callback

Return Value

ScheduledEvent

void runBeforeCallback()

Execute the before callback

Return Value

void

void runAfterCallback()

Execute the after callback

Return Value

void

void runFailedCallback(Throwable $exception)

Execute the failed callback

Parameters

Throwable $exception

Return Value

void

DateTime|null getLastRunAt()

Get the last run time

Return Value

DateTime|null

bool isRunning()

Check if the event is currently running

Return Value

bool

string getCronExpression()

Get the cron expression for this event

Return Value

string

string|null getOutput()

Get the output from the last execution

Return Value

string|null

int|null getExitCode()

Get the exit code from the last execution

Return Value

int|null

string getDescription()

Get the event description

Return Value

string