CronExpression::factory()
Factory method to create a new CronExpression.
Method of the class: CronExpression{}
No Hooks.
Return
CronExpression
.
Usage
$result = CronExpression::factory( $expression, $fieldFactory );
- $expression(string) (required)
- The CRON expression to create. There are
php several special predefined values which can be used to substitute the CRON expression:
@yearly, @annually) - Run once a year, midnight, Jan. 1 - 0 0 1 1 * @monthly - Run once a month, midnight, first of month - 0 0 1 * * @weekly - Run once a week, midnight on Sun - 0 0 * * 0 @daily - Run once a day, midnight - 0 0 * * * @hourly - Run once an hour, first minute - 0 * * * *
- $fieldFactory(CronExpression_FieldFactory)
- (optional) Field factory to use
Default: null
CronExpression::factory() CronExpression::factory code WC 9.5.1
public static function factory($expression, CronExpression_FieldFactory $fieldFactory = null) { $mappings = array( '@yearly' => '0 0 1 1 *', '@annually' => '0 0 1 1 *', '@monthly' => '0 0 1 * *', '@weekly' => '0 0 * * 0', '@daily' => '0 0 * * *', '@hourly' => '0 * * * *' ); if (isset($mappings[$expression])) { $expression = $mappings[$expression]; } return new self($expression, $fieldFactory ? $fieldFactory : new CronExpression_FieldFactory()); }