PHP Class Crunz\Event

Afficher le fichier Open project: lavary/crunz Class Usage Examples

Méthodes publiques

Свойство Type Description
$description string The human readable description of the event.
$output string The location that output should be sent to.
$outputStream string Event generated output
$preventOverlapping boolean Indicates if the command should not overlap itself.
$shouldAppendOutput boolean Indicates whether output should be appended.

Protected Properties

Свойство Type Description
$afterCallbacks array The array of callbacks to be run after the event is finished.
$beforeCallbacks array The array of callbacks to be run before the event is started.
$command string The command string.
$cwd string Current working directory
$expression string The cron expression representing the event's frequency.
$fieldsPosition array Position of cron fields
$filters array The array of filter callbacks.
$id string The event's unique identifier
$process Symfony\Component\Process\Process Process that runs the event
$rejects array The array of reject callbacks.
$timezone DateTimeZone | string The timezone the date should be evaluated on.
$user string The user the command should run as.

Méthodes publiques

Méthode Description
__call ( string $methodName, array $params ) Handling dynamic frequency methods
__construct ( $id, string $command ) : void Create a new event instance.
after ( Closure $callback ) Register a callback to be called after the operation.
afterCallbacks ( ) : array Return all registered after callbacks
appendOutputTo ( string $location ) Append the output of the command to a given location.
at ( string $time ) Schedule the command at a given time.
before ( Closure $callback ) Register a callback to be called before the operation.
beforeCallbacks ( ) : array Return all registered before callbacks
between ( $from, $to ) Set Working period
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).
dayOfMonth ( mixed $value ) Set hour for the cron job
dayOfWeek ( mixed $value ) Set hour for the cron job
days ( mixed $days ) Set the days of the week the command should run on.
description ( string $description ) Set the human-friendly description of the event.
every ( string $unit = null, string $value = null ) Another way to the frequency of the cron job
filtersPass ( ) : boolean Determine if the filters pass for the event.
fridays ( ) Schedule the event to run only on Fridays.
from ( string $datetime ) Check if event should be on
getCommand ( ) : string Return the event's command
getCommandForDisplay ( ) : string Get the command for display
getExpression ( ) : string Get the Cron expression for the event.
getId ( ) : string Return the event's command
getOutputStream ( ) : string Return event's full output
getProcess ( ) : Process Return the event's process
getSummaryForDisplay ( ) : string Get the summary of the event for display.
getWorkingDirectory ( ) : string Return the current working directory
hour ( mixed $value ) Set hour for the cron job
hourly ( ) Schedule the event to run hourly.
in ( string $directory ) Change the current working directory.
isClosure ( ) : boolean Determine whether the passed value is a closure ot not.
isDue ( ) : boolean Determine if the given event should run based on the Cron expression.
isLocked ( ) : boolean Check if another instance of the event is still running
lastPid ( ) : integer Get the last process Id of the event
lockFile ( ) : string Get the lock file path for the task
minute ( mixed $value ) Set minute for the cron job
mondays ( ) Schedule the event to run only on Mondays.
month ( mixed $value ) Set hour for the cron job
monthly ( ) Schedule the event to run monthly.
name ( string $description ) Set the human-friendly description of the event.
nullOutput ( ) : boolean Determine if the event's output is sent to null.
on ( string $date ) Schedule the event to run on a certain date
pingBefore ( string $url ) Register a callback to ping a given URL before the job runs.
preventOverlapping ( ) Do not allow the event to overlap each other.
quarterly ( ) Schedule the event to run quarterly.
saturdays ( ) Schedule the event to run only on Saturdays.
sendOutputTo ( string $location, boolean $append = false ) Send the output of the command to a given location.
setCommand ( string $command ) Set the event's command
setProcess ( Process $process = null ) Set the event's process
skip ( Closure $callback ) Register a callback to further filter the schedule.
start ( ) : integer Start the event execution
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 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.
to ( string $datetime ) Check if event should be off
tuesdays ( ) Schedule the event to run only on Tuesdays.
twiceDaily ( integer $first = 1, integer $second = 13 ) 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.

Méthodes protégées

Méthode Description
applyMask ( string $unit ) : string Mask a cron expression
expressionPasses ( ) : boolean Determine if the Cron expression passes.
getDefaultOutput ( ) : string Get the default output depending on the OS.
lock ( ) : string Lock the event
notYet ( $datetime ) : boolean Check if time hasn't arrived
past ( $datetime ) : boolean Check if the time has passed
serializeClosure ( string $closure ) : string Convert closure to an executable command
spliceIntoPosition ( integer $position, string $value ) Splice the given value into the given position of the expression.
sudo ( string $user ) : string Add sudo to the command

Method Details

__call() public méthode

Handling dynamic frequency methods
public __call ( string $methodName, array $params )
$methodName string
$params array

__construct() public méthode

Create a new event instance.
public __construct ( $id, string $command ) : void
$command string
Résultat void

after() public méthode

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

afterCallbacks() public méthode

Return all registered after callbacks
public afterCallbacks ( ) : array
Résultat array

appendOutputTo() public méthode

Append the output of the command to a given location.
public appendOutputTo ( string $location )
$location string

applyMask() protected méthode

Mask a cron expression
protected applyMask ( string $unit ) : string
$unit string
Résultat string

at() public méthode

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

before() public méthode

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

beforeCallbacks() public méthode

Return all registered before callbacks
public beforeCallbacks ( ) : array
Résultat array

between() public méthode

Set Working period
public between ( $from, $to )

buildCommand() public méthode

Build the comand string.
public buildCommand ( ) : string
Résultat string

cron() public méthode

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

daily() public méthode

Schedule the event to run daily.
public daily ( )

dailyAt() public méthode

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

dayOfMonth() public méthode

Set hour for the cron job
public dayOfMonth ( mixed $value )
$value mixed

dayOfWeek() public méthode

Set hour for the cron job
public dayOfWeek ( mixed $value )
$value mixed

days() public méthode

Set the days of the week the command should run on.
public days ( mixed $days )
$days mixed

description() public méthode

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

every() public méthode

Another way to the frequency of the cron job
public every ( string $unit = null, string $value = null )
$unit string
$value string

expressionPasses() protected méthode

Determine if the Cron expression passes.
protected expressionPasses ( ) : boolean
Résultat boolean

filtersPass() public méthode

Determine if the filters pass for the event.
public filtersPass ( ) : boolean
Résultat boolean

fridays() public méthode

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

from() public méthode

Check if event should be on
public from ( string $datetime )
$datetime string

getCommand() public méthode

Return the event's command
public getCommand ( ) : string
Résultat string

getCommandForDisplay() public méthode

Get the command for display
public getCommandForDisplay ( ) : string
Résultat string

getDefaultOutput() protected méthode

Get the default output depending on the OS.
protected getDefaultOutput ( ) : string
Résultat string

getExpression() public méthode

Get the Cron expression for the event.
public getExpression ( ) : string
Résultat string

getId() public méthode

Return the event's command
public getId ( ) : string
Résultat string

getOutputStream() public méthode

Return event's full output
public getOutputStream ( ) : string
Résultat string

getProcess() public méthode

Return the event's process
public getProcess ( ) : Process
Résultat Symfony\Component\Process\Process $process

getSummaryForDisplay() public méthode

Get the summary of the event for display.
public getSummaryForDisplay ( ) : string
Résultat string

getWorkingDirectory() public méthode

Return the current working directory
public getWorkingDirectory ( ) : string
Résultat string

hour() public méthode

Set hour for the cron job
public hour ( mixed $value )
$value mixed

hourly() public méthode

Schedule the event to run hourly.
public hourly ( )

in() public méthode

Change the current working directory.
public in ( string $directory )
$directory string

isClosure() public méthode

Determine whether the passed value is a closure ot not.
public isClosure ( ) : boolean
Résultat boolean

isDue() public méthode

Determine if the given event should run based on the Cron expression.
public isDue ( ) : boolean
Résultat boolean

isLocked() public méthode

Check if another instance of the event is still running
public isLocked ( ) : boolean
Résultat boolean

lastPid() public méthode

Get the last process Id of the event
public lastPid ( ) : integer
Résultat integer

lock() protected méthode

Lock the event
protected lock ( ) : string
Résultat string

lockFile() public méthode

Get the lock file path for the task
public lockFile ( ) : string
Résultat string

minute() public méthode

Set minute for the cron job
public minute ( mixed $value )
$value mixed

mondays() public méthode

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

month() public méthode

Set hour for the cron job
public month ( mixed $value )
$value mixed

monthly() public méthode

Schedule the event to run monthly.
public monthly ( )

name() public méthode

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

notYet() protected méthode

Check if time hasn't arrived
protected notYet ( $datetime ) : boolean
Résultat boolean

nullOutput() public méthode

Determine if the event's output is sent to null.
public nullOutput ( ) : boolean
Résultat boolean

on() public méthode

Schedule the event to run on a certain date
public on ( string $date )
$date string

past() protected méthode

Check if the time has passed
protected past ( $datetime ) : boolean
Résultat boolean

pingBefore() public méthode

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

preventOverlapping() public méthode

Do not allow the event to overlap each other.
public preventOverlapping ( )

quarterly() public méthode

Schedule the event to run quarterly.
public quarterly ( )

saturdays() public méthode

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

sendOutputTo() public méthode

Send the output of the command to a given location.
public sendOutputTo ( string $location, boolean $append = false )
$location string
$append boolean

serializeClosure() protected méthode

Convert closure to an executable command
protected serializeClosure ( string $closure ) : string
$closure string
Résultat string

setCommand() public méthode

Set the event's command
public setCommand ( string $command )
$command string

setProcess() public méthode

Set the event's process
public setProcess ( Process $process = null )
$process Symfony\Component\Process\Process

skip() public méthode

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

spliceIntoPosition() protected méthode

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

start() public méthode

Start the event execution
public start ( ) : integer
Résultat integer

sudo() protected méthode

Add sudo to the command
protected sudo ( string $user ) : string
$user string
Résultat string

sundays() public méthode

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

then() public méthode

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

thenPing() public méthode

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

thursdays() public méthode

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

timezone() public méthode

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

to() public méthode

Check if event should be off
public to ( string $datetime )
$datetime string

tuesdays() public méthode

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

twiceDaily() public méthode

Schedule the event to run twice daily.
public twiceDaily ( integer $first = 1, integer $second = 13 )
$first integer
$second integer

user() public méthode

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

wednesdays() public méthode

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

weekdays() public méthode

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

weekly() public méthode

Schedule the event to run weekly.
public weekly ( )

weeklyOn() public méthode

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 méthode

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

yearly() public méthode

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
Résultat array

$beforeCallbacks protected_oe property

The array of callbacks to be run before the event is started.
protected array $beforeCallbacks
Résultat array

$command protected_oe property

The command string.
protected string $command
Résultat string

$cwd protected_oe property

Current working directory
protected string $cwd
Résultat string

$description public_oe property

The human readable description of the event.
public string $description
Résultat string

$expression protected_oe property

The cron expression representing the event's frequency.
protected string $expression
Résultat string

$fieldsPosition protected_oe property

Position of cron fields
protected array $fieldsPosition
Résultat array

$filters protected_oe property

The array of filter callbacks.
protected array $filters
Résultat array

$id protected_oe property

The event's unique identifier
protected string $id
Résultat string

$output public_oe property

The location that output should be sent to.
public string $output
Résultat string

$outputStream public_oe property

Event generated output
public string $outputStream
Résultat string

$preventOverlapping public_oe property

Indicates if the command should not overlap itself.
public bool $preventOverlapping
Résultat boolean

$process protected_oe property

Process that runs the event
protected Process,Symfony\Component\Process $process
Résultat Symfony\Component\Process\Process

$rejects protected_oe property

The array of reject callbacks.
protected array $rejects
Résultat array

$shouldAppendOutput public_oe property

Indicates whether output should be appended.
public bool $shouldAppendOutput
Résultat boolean

$timezone protected_oe property

The timezone the date should be evaluated on.
protected DateTimeZone|string $timezone
Résultat DateTimeZone | string

$user protected_oe property

The user the command should run as.
protected string $user
Résultat string