Joomla CMS  4.2.2
Documentation des API du CMS Joomla en version 4.2.2
Référence de la classe CronExpression

Fonctions membres publiques

 __construct (string $expression, FieldFactoryInterface $fieldFactory=null)
 
 setExpression (string $value)
 
 setPart (int $position, string $value)
 
 setMaxIterationCount (int $maxIterationCount)
 
 getNextRunDate ($currentTime='now', int $nth=0, bool $allowCurrentDate=false, $timeZone=null)
 
 getPreviousRunDate ($currentTime='now', int $nth=0, bool $allowCurrentDate=false, $timeZone=null)
 
 getMultipleRunDates (int $total, $currentTime='now', bool $invert=false, bool $allowCurrentDate=false, $timeZone=null)
 
 getExpression ($part=null)
 
 getParts ()
 
 __toString ()
 
 isDue ($currentTime='now', $timeZone=null)
 

Fonctions membres publiques statiques

static registerAlias (string $alias, string $expression)
 
static unregisterAlias (string $alias)
 
static supportsAlias (string $alias)
 
static getAliases ()
 
static factory (string $expression, FieldFactoryInterface $fieldFactory=null)
 
static isValidExpression (string $expression)
 

Champs de données

const MINUTE = 0
 
const HOUR = 1
 
const DAY = 2
 
const MONTH = 3
 
const WEEKDAY = 4
 
const YEAR = 5
 
const MAPPINGS
 

Fonctions membres protégées

 getRunDate ($currentTime=null, int $nth=0, bool $invert=false, bool $allowCurrentDate=false, $timeZone=null)
 
 determineTimeZone ($currentTime, ?string $timeZone)
 

Attributs protégés

 $cronParts
 
 $fieldFactory
 
 $maxIterationCount = 1000
 

Attributs protégés statiques

static $order
 

Attributs privés statiques

static $registeredAliases = self::MAPPINGS
 

Description détaillée

CRON expression parser that can determine whether or not a CRON expression is due to run, the next run date and previous run date of a CRON expression. The determinations made by this class are accurate if checked run once per minute (seconds are dropped from date time comparisons).

Schedule parts must map to: minute [0-59], hour [0-23], day of month, month [1-12|JAN-DEC], day of week [1-7|MON-SUN], and an optional year.

Voir également
http://en.wikipedia.org/wiki/Cron

Documentation des constructeurs et destructeur

◆ __construct()

__construct ( string  $expression,
FieldFactoryInterface  $fieldFactory = null 
)

Parse a CRON expression.

Paramètres
string$expressionCRON expression (e.g. '8 * * * *')
null | FieldFactoryInterface$fieldFactoryFactory to create cron fields

Documentation des fonctions membres

◆ __toString()

__toString ( )

Helper method to output the full expression.

Renvoie
string Full CRON expression

◆ determineTimeZone()

determineTimeZone (   $currentTime,
?string  $timeZone 
)
protected

Workout what timeZone should be used.

Paramètres
string | \DateTimeInterface | null$currentTimeRelative calculation date
string | null$timeZoneTimeZone to use instead of the system default
Renvoie
string

Références null.

◆ factory()

FieldFactoryInterface CRON field factory ( string  $expression,
FieldFactoryInterface  $fieldFactory = null 
)
static
Obsolète:
since version 3.0.2, use __construct instead.

-ignore-next-line

◆ getAliases()

static getAliases ( )
static

Returns all registered aliases as an associated array where the aliases are the key and their associated expressions are the values.

Renvoie
array<string, string>

◆ getExpression()

getExpression (   $part = null)

Get all or part of the CRON expression.

Paramètres
int | string | null$partspecify the part to retrieve or NULL to get the full cron schedule string
Renvoie
null|string Returns the CRON expression, a part of the CRON expression, or NULL if the part was specified but not found

Références null.

◆ getMultipleRunDates()

getMultipleRunDates ( int  $total,
  $currentTime = 'now',
bool  $invert = false,
bool  $allowCurrentDate = false,
  $timeZone = null 
)

Get multiple run dates starting at the current date or a specific date.

Paramètres
int$totalSet the total number of dates to calculate
string | \DateTimeInterface | null$currentTimeRelative calculation date
bool$invertSet to TRUE to retrieve previous dates
bool$allowCurrentDateSet to TRUE to return the current date if it matches the cron expression
null | string$timeZoneTimeZone to use instead of the system default
Renvoie
[] Returns an array of run dates

Références $i, $result, $total, class, et elseif.

◆ getNextRunDate()

getNextRunDate (   $currentTime = 'now',
int  $nth = 0,
bool  $allowCurrentDate = false,
  $timeZone = null 
)

Get a next run date relative to the current date or a specific date

Paramètres
string | \DateTimeInterface$currentTimeRelative calculation date
int$nthNumber of matches to skip before returning a matching next run date. 0, the default, will return the current date and time if the next run date falls on the current date and time. Setting this value to 1 will skip the first match and go to the second match. Setting this value to 2 will skip the first 2 matches and so on.
bool$allowCurrentDateSet to TRUE to return the current date if it matches the cron expression.
null | string$timeZoneTimeZone to use instead of the system default
Exceptions

◆ getParts()

getParts ( )

Gets the parts of the cron expression as an array.

Renvoie
string[] The array of parts that make up this expression.

◆ getPreviousRunDate()

getPreviousRunDate (   $currentTime = 'now',
int  $nth = 0,
bool  $allowCurrentDate = false,
  $timeZone = null 
)

Get a previous run date relative to the current date or a specific date.

Paramètres
string | \DateTimeInterface$currentTimeRelative calculation date
int$nthNumber of matches to skip before returning
bool$allowCurrentDateSet to TRUE to return the current date if it matches the cron expression
null | string$timeZoneTimeZone to use instead of the system default
Exceptions

◆ getRunDate()

getRunDate (   $currentTime = null,
int  $nth = 0,
bool  $invert = false,
bool  $allowCurrentDate = false,
  $timeZone = null 
)
protected

Get the next or previous run date of the expression relative to a date.

Paramètres
string | \DateTimeInterface | null$currentTimeRelative calculation date
int$nthNumber of matches to skip before returning
bool$invertSet to TRUE to go backwards in time
bool$allowCurrentDateSet to TRUE to return the current date if it matches the cron expression
string | null$timeZoneTimeZone to use instead of the system default
Exceptions

Références $b, $currentDate, $field, $fields, $i, $parts, $position, class, elseif, et null.

◆ isDue()

isDue (   $currentTime = 'now',
  $timeZone = null 
)

Determine if the cron is due to run based on the current date or a specific date. This method assumes that the current number of seconds are irrelevant, and should be called once per minute.

Paramètres
string | \DateTimeInterface$currentTimeRelative calculation date
null | string$timeZoneTimeZone to use instead of the system default
Renvoie
bool Returns TRUE if the cron is due to run or FALSE if not

Références class, et elseif.

◆ isValidExpression()

static isValidExpression ( string  $expression)
static

Validate a CronExpression.

Paramètres
string$expressionthe CRON expression to validate
Renvoie
bool True if a valid CRON expression was passed. False if not.

◆ registerAlias()

static registerAlias ( string  $alias,
string  $expression 
)
static

Registered a user defined CRON Expression Alias.

Exceptions
LogicExceptionIf the expression or the alias name are invalid or if the alias is already registered.

◆ setExpression()

setExpression ( string  $value)

Set or change the CRON expression.

Paramètres
string$valueCRON expression (e.g. 8 * * * *)
Exceptions

Références $position, $this, et $value.

◆ setMaxIterationCount()

setMaxIterationCount ( int  $maxIterationCount)

Set max iteration count for searching next run dates.

Paramètres
int$maxIterationCountMax iteration count when searching for next run date
Renvoie
CronExpression

Références $this.

◆ setPart()

setPart ( int  $position,
string  $value 
)

Set part of the CRON expression.

Paramètres
int$positionThe position of the CRON expression to set
string$valueThe value to set
Exceptions

Références $position, $this, et $value.

◆ supportsAlias()

static supportsAlias ( string  $alias)
static

Tells whether a CRON Expression alias is registered.

◆ unregisterAlias()

static unregisterAlias ( string  $alias)
static

Unregistered a user defined CRON Expression Alias.

Exceptions
LogicExceptionIf the user tries to unregister a built-in alias

Documentation des champs

◆ $cronParts

$cronParts
protected

◆ $fieldFactory

$fieldFactory
protected

◆ $maxIterationCount

$maxIterationCount = 1000
protected

◆ $order

$order
staticprotected
Valeur initiale :
= [
self::YEAR,
self::MONTH,
self::DAY,
self::WEEKDAY,
self::HOUR,
self::MINUTE,
]

◆ $registeredAliases

$registeredAliases = self::MAPPINGS
staticprivate

◆ DAY

const DAY = 2

◆ HOUR

const HOUR = 1

◆ MAPPINGS

const MAPPINGS
Valeur initiale :
= [
'@yearly' => '0 0 1 1 *'

◆ MINUTE

const MINUTE = 0

◆ MONTH

const MONTH = 3

◆ WEEKDAY

const WEEKDAY = 4

◆ YEAR

const YEAR = 5

La documentation de cette classe a été générée à partir du fichier suivant :