PHP Class omnilight\scheduling\Event

Inheritance: extends yii\base\Component
ファイルを表示 Open project: omnilight/yii2-scheduling Class Usage Examples

Public Properties

Property Type Description
$command string Command string

Protected Properties

Property Type Description
$_afterCallbacks array The array of callbacks to be run after the event is finished.
$_description string The human readable description of the event.
$_expression string The cron expression representing the event's frequency.
$_filter Closure The filter callback.
$_output string The location that output should be sent to.
$_reject Closure The reject callback.
$_timezone DateTimeZone | string The timezone the date should be evaluated on.
$_user string The user the command should run as.

Public Methods

Method Description
__construct ( string $command, array $config = [] ) Create a new event instance.
at ( string $time ) Schedule the command at a given time.
buildCommand ( ) : string Build the comand string.
cron ( string $expression ) The Cron expression representing the event's frequency.
daily ( ) Schedule the event to run daily.
dailyAt ( string $time ) Schedule the event to run daily at a given time (10:00, 19:30, etc).
days ( array | integer $days ) Set the days of the week the command should run on.
description ( string $description ) Set the human-friendly description of the event.
emailOutputTo ( array $addresses ) E-mail the results of the scheduled operation.
everyFiveMinutes ( ) Schedule the event to run every five minutes.
everyMinute ( ) Schedule the event to run every minute.
everyNMinutes ( integer | string $minutes ) Schedule the event to run every N minutes.
everyTenMinutes ( ) Schedule the event to run every ten minutes.
everyThirtyMinutes ( ) Schedule the event to run every thirty minutes.
fridays ( ) Schedule the event to run only on Fridays.
getDefaultOutput ( )
getExpression ( ) : string Get the Cron expression for the event.
getSummaryForDisplay ( ) : string Get the summary of the event for display.
hourly ( ) Schedule the event to run hourly.
isDue ( Application $app ) : boolean Determine if the given event should run based on the Cron expression.
mondays ( ) Schedule the event to run only on Mondays.
monthly ( ) Schedule the event to run monthly.
run ( Application $app ) Run the given event.
saturdays ( ) Schedule the event to run only on Saturdays.
sendOutputTo ( string $location ) Send the output of the command to a given location.
skip ( Closure $callback ) Register a callback to further filter the schedule.
sundays ( ) Schedule the event to run only on Sundays.
then ( Closure $callback ) Register a callback to be called after the operation.
thenPing ( string $url ) Register a callback to the ping a given URL after the job runs.
thursdays ( ) Schedule the event to run only on Thursdays.
timezone ( DateTimeZone | string $timezone ) Set the timezone the date should be evaluated on.
tuesdays ( ) Schedule the event to run only on Tuesdays.
twiceDaily ( ) Schedule the event to run twice daily.
user ( string $user ) Set which user the command should run as.
wednesdays ( ) Schedule the event to run only on Wednesdays.
weekdays ( ) Schedule the event to run only on weekdays.
weekly ( ) Schedule the event to run weekly.
weeklyOn ( integer $day, string $time = '0:0' ) Schedule the event to run weekly on a given day and time.
when ( Closure $callback ) Register a callback to further filter the schedule.
yearly ( ) Schedule the event to run yearly.

Protected Methods

Method Description
callAfterCallbacks ( Application $app ) Call all of the "after" callbacks for the event.
emailOutput ( yii\mail\MailerInterface $mailer, array $addresses ) E-mail the output of the event to the recipients.
expressionPasses ( ) : boolean Determine if the Cron expression passes.
filtersPass ( Application $app ) : boolean Determine if the filters pass for the event.
getEmailSubject ( ) : string Get the e-mail subject line for output results.
runCommandInBackground ( Application $app ) Run the command in the background using exec.
runCommandInForeground ( Application $app ) Run the command in the foreground.
spliceIntoPosition ( integer $position, string $value ) : Event Splice the given value into the given position of the expression.

Method Details

__construct() public method

Create a new event instance.
public __construct ( string $command, array $config = [] )
$command string
$config array

at() public method

Schedule the command at a given time.
public at ( string $time )
$time string

buildCommand() public method

Build the comand string.
public buildCommand ( ) : string
return string

callAfterCallbacks() protected method

Call all of the "after" callbacks for the event.
protected callAfterCallbacks ( Application $app )
$app yii\base\Application

cron() public method

The Cron expression representing the event's frequency.
public cron ( string $expression )
$expression string

daily() public method

Schedule the event to run daily.
public daily ( )

dailyAt() public method

Schedule the event to run daily at a given time (10:00, 19:30, etc).
public dailyAt ( string $time )
$time string

days() public method

Set the days of the week the command should run on.
public days ( array | integer $days )
$days array | integer

description() public method

Set the human-friendly description of the event.
public description ( string $description )
$description string

emailOutput() protected method

E-mail the output of the event to the recipients.
protected emailOutput ( yii\mail\MailerInterface $mailer, array $addresses )
$mailer yii\mail\MailerInterface
$addresses array

emailOutputTo() public method

E-mail the results of the scheduled operation.
public emailOutputTo ( array $addresses )
$addresses array

everyFiveMinutes() public method

Schedule the event to run every five minutes.
public everyFiveMinutes ( )

everyMinute() public method

Schedule the event to run every minute.
public everyMinute ( )

everyNMinutes() public method

Schedule the event to run every N minutes.
public everyNMinutes ( integer | string $minutes )
$minutes integer | string

everyTenMinutes() public method

Schedule the event to run every ten minutes.
public everyTenMinutes ( )

everyThirtyMinutes() public method

Schedule the event to run every thirty minutes.
public everyThirtyMinutes ( )

expressionPasses() protected method

Determine if the Cron expression passes.
protected expressionPasses ( ) : boolean
return boolean

filtersPass() protected method

Determine if the filters pass for the event.
protected filtersPass ( Application $app ) : boolean
$app yii\base\Application
return boolean

fridays() public method

Schedule the event to run only on Fridays.
public fridays ( )

getDefaultOutput() public method

public getDefaultOutput ( )

getEmailSubject() protected method

Get the e-mail subject line for output results.
protected getEmailSubject ( ) : string
return string

getExpression() public method

Get the Cron expression for the event.
public getExpression ( ) : string
return string

getSummaryForDisplay() public method

Get the summary of the event for display.
public getSummaryForDisplay ( ) : string
return string

hourly() public method

Schedule the event to run hourly.
public hourly ( )

isDue() public method

Determine if the given event should run based on the Cron expression.
public isDue ( Application $app ) : boolean
$app yii\base\Application
return boolean

mondays() public method

Schedule the event to run only on Mondays.
public mondays ( )

monthly() public method

Schedule the event to run monthly.
public monthly ( )

run() public method

Run the given event.
public run ( Application $app )
$app yii\base\Application

runCommandInBackground() protected method

Run the command in the background using exec.
protected runCommandInBackground ( Application $app )
$app yii\base\Application

runCommandInForeground() protected method

Run the command in the foreground.
protected runCommandInForeground ( Application $app )
$app yii\base\Application

saturdays() public method

Schedule the event to run only on Saturdays.
public saturdays ( )

sendOutputTo() public method

Send the output of the command to a given location.
public sendOutputTo ( string $location )
$location string

skip() public method

Register a callback to further filter the schedule.
public skip ( Closure $callback )
$callback Closure

spliceIntoPosition() protected method

Splice the given value into the given position of the expression.
protected spliceIntoPosition ( integer $position, string $value ) : Event
$position integer
$value string
return Event

sundays() public method

Schedule the event to run only on Sundays.
public sundays ( )

then() public method

Register a callback to be called after the operation.
public then ( Closure $callback )
$callback Closure

thenPing() public method

Register a callback to the ping a given URL after the job runs.
public thenPing ( string $url )
$url string

thursdays() public method

Schedule the event to run only on Thursdays.
public thursdays ( )

timezone() public method

Set the timezone the date should be evaluated on.
public timezone ( DateTimeZone | string $timezone )
$timezone DateTimeZone | string

tuesdays() public method

Schedule the event to run only on Tuesdays.
public tuesdays ( )

twiceDaily() public method

Schedule the event to run twice daily.
public twiceDaily ( )

user() public method

Set which user the command should run as.
public user ( string $user )
$user string

wednesdays() public method

Schedule the event to run only on Wednesdays.
public wednesdays ( )

weekdays() public method

Schedule the event to run only on weekdays.
public weekdays ( )

weekly() public method

Schedule the event to run weekly.
public weekly ( )

weeklyOn() public method

Schedule the event to run weekly on a given day and time.
public weeklyOn ( integer $day, string $time = '0:0' )
$day integer
$time string

when() public method

Register a callback to further filter the schedule.
public when ( Closure $callback )
$callback Closure

yearly() public method

Schedule the event to run yearly.
public yearly ( )

Property Details

$_afterCallbacks protected_oe property

The array of callbacks to be run after the event is finished.
protected array $_afterCallbacks
return array

$_description protected_oe property

The human readable description of the event.
protected string $_description
return string

$_expression protected_oe property

The cron expression representing the event's frequency.
protected string $_expression
return string

$_filter protected_oe property

The filter callback.
protected Closure $_filter
return Closure

$_output protected_oe property

The location that output should be sent to.
protected string $_output
return string

$_reject protected_oe property

The reject callback.
protected Closure $_reject
return Closure

$_timezone protected_oe property

The timezone the date should be evaluated on.
protected DateTimeZone|string $_timezone
return DateTimeZone | string

$_user protected_oe property

The user the command should run as.
protected string $_user
return string

$command public_oe property

Command string
public string $command
return string