ScheduledEvent
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
Create a new scheduled event
Get the schedule instance
Get the event type
Get the event target
Get the mutex name for this event
Set a custom mutex name
Run the scheduled event
Execute the event based on its type
Execute a Bow console command
Execute a QueueTask
Set the queue connection to use for task execution
Get the queue connection
Execute a shell command
Execute a closure/callback
Build a Bow console command
Run a shell command
Run command in background
Get the path to the bow executable
Register a before callback
Register an after callback
Register a failed callback
Execute the before callback
Execute the after callback
Get the last run time
Check if the event is currently running
Get the cron expression for this event
Get the output from the last execution
Get the exit code from the last execution
Get the event description
Details
void
__construct(string $type, mixed $target, array $parameters = [])
Create a new scheduled event
Schedule
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
ScheduledEvent
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
protected void
execute()
Execute the event based on its type
protected void
executeCommand()
Execute a Bow console command
protected void
executeTask()
Execute a QueueTask
protected void
pushToQueue(QueueTask $task)
Push the task to a queue connection
ScheduledEvent
onConnection(string $connection)
Set the queue connection to use for task execution
string|null
getConnection()
Get the queue connection
protected void
executeExec()
Execute a shell command
protected void
executeCall()
Execute a closure/callback
protected string
buildBowCommand()
Build a Bow console command
protected void
runShellCommand(string $command)
Run a shell command
protected void
runInBackground(string $command)
Run command in background
protected string
getBowPath()
Get the path to the bow executable
ScheduledEvent
before(callable $callback)
Register a before callback
ScheduledEvent
after(callable $callback)
Register an after callback
ScheduledEvent
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