Event
Uses
Properties
$command string|null
The command string.
$expression string
The cron expression representing the event's frequency.
$repeatSeconds int|null
How often to repeat the event during a minute.
$user string|null
The user the command should run as.
$environments array
The list of environments the command should run under.
$evenInMaintenanceMode bool
Indicates if the command should run in maintenance mode.
$withoutOverlapping bool
Indicates if the command should not overlap itself.
$onOneServer bool
Indicates if the command should only be allowed to run on one server for each cron expression.
$expiresAt int
The number of minutes the mutex should be valid.
$runInBackground bool
Indicates if the command should run in the background.
$filters array
The array of filter callbacks.
$rejects array
The array of reject callbacks.
$output string
The location that output should be sent to.
$shouldAppendOutput bool
Indicates whether output should be appended.
$beforeCallbacks array
The array of callbacks to be run before the event is started.
$afterCallbacks array
The array of callbacks to be run after the event is finished.
$description string|null
The human readable description of the event.
$lastChecked Carbon |null
The last time the event was checked for eligibility to run.
Utilized by sub-minute repeated events.
$exitCode int|null
The exit status code of the command.
Methods
__construct ( EventMutex $mutex , $command , $timezone ) : void
Create a new event instance.
Parameters
- $mutex EventMutex
- $command string
- $timezone DateTimeZone |string|null
getDefaultOutput ( ) : string
Get the default output depending on the OS.
shouldSkipDueToOverlapping ( ) : bool
Determine if the event should skip because another process is overlapping.
isRepeatable ( ) : bool
Determine if the event has been configured to repeat multiple times per minute.
shouldRepeatNow ( ) : bool
Determine if the event is ready to repeat.
finish ( Container $container , $exitCode ) : void
Mark the command process as finished and run callbacks/cleanup.
Parameters
- $container Container
- $exitCode int
callBeforeCallbacks ( Container $container ) : void
Call all of the "before" callbacks for the event.
Parameters
- $container Container
callAfterCallbacks ( Container $container ) : void
Call all of the "after" callbacks for the event.
Parameters
- $container Container
buildCommand ( ) : string
Build the command string.
isDue ( $app ) : bool
Determine if the given event should run based on the Cron expression.
Parameters
- $app Application
runsInMaintenanceMode ( ) : bool
Determine if the event runs in maintenance mode.
expressionPasses ( ) : bool
Determine if the Cron expression passes.
runsInEnvironment ( $environment ) : bool
Determine if the event runs in the given environment.
Parameters
- $environment string
filtersPass ( $app ) : bool
Determine if the filters pass for the event.
Parameters
- $app Application
storeOutput ( ) : $this
Ensure that the output is stored on disk in a log file.
sendOutputTo ( $location , $append ) : $this
Send the output of the command to a given location.
Parameters
- $location string
- $append bool
appendOutputTo ( $location ) : $this
Append the output of the command to a given location.
Parameters
- $location string
emailOutputTo ( $addresses , $onlyIfOutputExists ) : $this
E-mail the results of the scheduled operation.
Parameters
- $addresses array|mixed
- $onlyIfOutputExists bool
emailWrittenOutputTo ( $addresses ) : $this
E-mail the results of the scheduled operation if it produces output.
Parameters
- $addresses array|mixed
emailOutputOnFailure ( $addresses ) : $this
E-mail the results of the scheduled operation if it fails.
Parameters
- $addresses array|mixed
ensureOutputIsBeingCaptured ( ) : void
Ensure that the command output is being captured.
emailOutput ( Mailer $mailer , $addresses , $onlyIfOutputExists ) : void
E-mail the output of the event to the recipients.
Parameters
- $mailer Mailer
- $addresses array
- $onlyIfOutputExists bool
getEmailSubject ( ) : string
Get the e-mail subject line for output results.
pingBefore ( $url ) : $this
Register a callback to ping a given URL before the job runs.
Parameters
- $url string
pingBeforeIf ( $value , $url ) : $this
Register a callback to ping a given URL before the job runs if the given condition is true.
Parameters
- $value bool
- $url string
thenPing ( $url ) : $this
Register a callback to ping a given URL after the job runs.
Parameters
- $url string
thenPingIf ( $value , $url ) : $this
Register a callback to ping a given URL after the job runs if the given condition is true.
Parameters
- $value bool
- $url string
pingOnSuccess ( $url ) : $this
Register a callback to ping a given URL if the operation succeeds.
Parameters
- $url string
pingOnFailure ( $url ) : $this
Register a callback to ping a given URL if the operation fails.
Parameters
- $url string
pingCallback ( $url ) : Closure
Get the callback that pings the given URL.
Parameters
- $url string
getHttpClient ( Container $container ) : GuzzleHttp\ClientInterface
Get the Guzzle HTTP client to use to send pings.
Parameters
- $container Container
runInBackground ( ) : $this
State that the command should run in the background.
user ( $user ) : $this
Set which user the command should run as.
Parameters
- $user string
environments ( $environments ) : $this
Limit the environments the command should run in.
Parameters
- $environments array|mixed
evenInMaintenanceMode ( ) : $this
State that the command should run even in maintenance mode.
withoutOverlapping ( $expiresAt ) : $this
Do not allow the event to overlap each other.
Parameters
- $expiresAt int
onOneServer ( ) : $this
Allow the event to only run on one server for each cron expression.
when ( $callback ) : $this
Register a callback to further filter the schedule.
Parameters
- $callback Closure |bool
skip ( $callback ) : $this
Register a callback to further filter the schedule.
Parameters
- $callback Closure |bool
before ( Closure $callback ) : $this
Register a callback to be called before the operation.
Parameters
- $callback Closure
after ( Closure $callback ) : $this
Register a callback to be called after the operation.
Parameters
- $callback Closure
then ( Closure $callback ) : $this
Register a callback to be called after the operation.
Parameters
- $callback Closure
thenWithOutput ( Closure $callback , $onlyIfOutputExists ) : $this
Register a callback that uses the output after the job runs.
Parameters
- $callback Closure
- $onlyIfOutputExists bool
onSuccess ( Closure $callback ) : $this
Register a callback to be called if the operation succeeds.
Parameters
- $callback Closure
onSuccessWithOutput ( Closure $callback , $onlyIfOutputExists ) : $this
Register a callback that uses the output if the operation succeeds.
Parameters
- $callback Closure
- $onlyIfOutputExists bool
onFailure ( Closure $callback ) : $this
Register a callback to be called if the operation fails.
Parameters
- $callback Closure
onFailureWithOutput ( Closure $callback , $onlyIfOutputExists ) : $this
Register a callback that uses the output if the operation fails.
Parameters
- $callback Closure
- $onlyIfOutputExists bool
withOutputCallback ( Closure $callback , $onlyIfOutputExists ) : Closure
Get a callback that provides output.
Parameters
- $callback Closure
- $onlyIfOutputExists bool
name ( $description ) : $this
Set the human-friendly description of the event.
Parameters
- $description string
description ( $description ) : $this
Set the human-friendly description of the event.
Parameters
- $description string
getSummaryForDisplay ( ) : string
Get the summary of the event for display.
nextRunDate ( $currentTime , $nth , $allowCurrentDate ) : Carbon
Determine the next due date for an event.
Parameters
- $currentTime DateTimeInterface |string
- $nth int
- $allowCurrentDate bool
getExpression ( ) : string
Get the Cron expression for the event.
preventOverlapsUsing ( EventMutex $mutex ) : $this
Set the event mutex implementation to be used.
Parameters
- $mutex EventMutex
mutexName ( ) : string
Get the mutex name for the scheduled command.
createMutexNameUsing ( $mutexName ) : $this
Set the mutex name or name resolver callback.
Parameters
- $mutexName Closure |string
removeMutex ( ) : void
Delete the mutex for the event.