Overview

Packages

  • application
    • commands
    • components
      • actions
      • filters
      • leftWidget
      • permissions
      • sortableWidget
      • util
      • webupdater
      • x2flow
        • actions
        • triggers
      • X2GridView
      • X2Settings
    • controllers
    • models
      • embedded
    • modules
      • accounts
        • controllers
        • models
      • actions
        • controllers
        • models
      • calendar
        • controllers
        • models
      • charts
        • models
      • contacts
        • controllers
        • models
      • docs
        • components
        • controllers
        • models
      • groups
        • controllers
        • models
      • marketing
        • components
        • controllers
        • models
      • media
        • controllers
        • models
      • mobile
        • components
      • opportunities
        • controllers
        • models
      • products
        • controllers
        • models
      • quotes
        • controllers
        • models
      • services
        • controllers
        • models
      • template
        • models
      • users
        • controllers
        • models
      • workflow
        • controllers
        • models
      • x2Leads
        • controllers
        • models
  • None
  • system
    • base
    • caching
    • console
    • db
      • ar
      • schema
    • validators
    • web
      • actions
      • auth
      • helpers
      • widgets
        • captcha
        • pagers
  • zii
    • widgets
      • grid

Classes

  • AppFileUtil
  • CommandUtil
  • CrontabUtil
  • EncryptUtil
  • FileUtil
  • Overview
  • Package
  • Class
  • Tree

Class CrontabUtil

Class providing an abstraction layer for cron table editing.

Abstracted data comes in the form (for each line of the X2Engine-managed section of the cron table): an array with keys

<dl> <dt>schedule</dt><dd>Preset schedule. If this key is set, min-dayOfWeek keys will not be set.</dd> <dt>min</dt><dd>Minutes of the hour at which to run</dd> <dt>hour</dt><dd>Hours of the day at which to run</dd> <dt>dayOfMonth</dt><dd>Days of the month at which to run</dd> <dt>month</dt><dd>Months of the year at which to run</dd> <dt>dayOfWeek</dt><dd>Days of the week at which to run</dd> <dt>cmd</dt><dd>The cmd to run</dd> <dt>tag</dt><dd>Unique string identifying the cron job</dd> <dt>desc</dt><dd>Brief one-line (no carraige returns) description</dd> </dl> For each of the above that are defined as plural, the values could be either an array of possible values or "*" for "all" (see https://en.wikipedia.org/wiki/Cron for more information on cron table formatting and specification).

NOTE: the crontab field and manged section delimeters are set the way they are for backwards compatibility (with old crontabs that use the old markers) despite the change in product naming (from X2Engine back to X2Engine).

Package: application\components\util
Author: Demitri Morgan <demitri@x2engine.com>
Located at x2engine/protected/components/util/CrontabUtil.php
Methods summary
public static
# addCronMarker( string & $crontab, boolean $check = false )

Adds delimiters for identifying X2Engine-managed cron tasks to the crontab, if they don't already exist.

Adds delimiters for identifying X2Engine-managed cron tasks to the crontab, if they don't already exist.

Parameters

$crontab
string
$crontab reference to the current cron table in string form.
$check
boolean
$check if enabled, an exception will be thrown in the event that no management delimeters were found.
public static
# arrayToCrontab( string & $crontab, array $crontabArray )

Modifies an existing cron table according to a specified array.

Modifies an existing cron table according to a specified array.

Parameters

$crontab
string
$crontab The existing cron table
$crontabArray
array
$crontabArray The array (each index a tag and each value an array as specified in this class's documentation)
public static
# cronJobToForm( mixed $crontabLine )

Takes a crontab line array and converts it to an array appropriate for pre-populating the cron job schedule/configuration form (i.e. with a preexisting cron job).

Takes a crontab line array and converts it to an array appropriate for pre-populating the cron job schedule/configuration form (i.e. with a preexisting cron job).

public static string
# crontabLine( type $l )

Formats a crontab line according to the specification defined in crontabArray

Formats a crontab line according to the specification defined in crontabArray

Parameters

$l
type
$l Line configuration array. Should have the keys specified in the main documentation of this class.

Returns

string
public static array
# crontabToArray( string & $crontab )

Parse the cron table into an array.

Parse the cron table into an array.

Each line is followed by a management delimeter, a tag (uniquely identifying string for the cron job) another management delimeter and a description.

Parameters

$crontab
string
$crontab The cron table.

Returns

array
public static string
# inputName( type $formName, type $tag, type $name, mixed $isArray = 0 )

Generates a form input name for a cron job configuration form section

Generates a form input name for a cron job configuration form section

Parameters

$formName
type
$name Name of the input
$tag
type
$formName Name of the form section to contain the cron input
$name
type
$isArray Whether the input will produce array-type data, i.e. a multi-select input
$isArray

Returns

string
public static
# jsName( mixed $name, mixed $tag )
public static boolean|array
# parseCrontabLine( string $line )

The inverse operation of CrontabUtil::crontabLine(); returns false if the line isn't compatible with specifications.

The inverse operation of CrontabUtil::crontabLine(); returns false if the line isn't compatible with specifications.

Does not support the "/" notation (i.e. /2 for every second of whatever time interval is being denoted)

Parameters

$line
string
$l The line to be parsed

Returns

boolean|array
False if the line isn't compatible with specifications, the parsed array otherwise
public static
# processForm( mixed $form = array() )

Takes data from an instance of the crontab form generated in CrontabUtil::schedForm() and creates a well-formatted array for creating a corresponding crontab entry.

Takes data from an instance of the crontab form generated in CrontabUtil::schedForm() and creates a well-formatted array for creating a corresponding crontab entry.

Can also initialize a cron job form field set from an empty array.

public static string
# schedForm( array $data = array(), string $name = 'cron', string $cmd = null, string $tag = 'default', string $desc = null )

Generate form inputs for creating a cron task.

Generate form inputs for creating a cron task.

Note, the JavaScript in this cron form is namespace-protected to allow multiple cron forms within the same page. The "name" argument should be used to control the name.

Parameters

$data
array
$data Previous form data submitted, if any.
$name
string
$name The name of the nested array in the form data containing information about the cron job. Must be usable as a JavaScript object name.
$cmd
string
$desc Optional description of cron job to save in crontab as a desc
$tag
string
$cmd The command to run at the scheuled dates. If unspecified,
$desc
string
$tag A "tag" in the comments uniquely identifying the cron job

Returns

string
public static type
# timeList( type $timeField )

Parameters

$timeField
type
$timeField The field to be parsed

Returns

type
Constants summary
string CRONTAB_FIELD_DELIM '#@X2CRM@'
#
string CRONTAB_MANAGED_BEGIN '#<X2CRM>'
#
string CRONTAB_MANAGED_END '#</X2CRM>'
#
Properties summary
public static type $printHint true
#

If set to true, the cron tab form will include the hint.

If set to true, the cron tab form will include the hint.

public static array $taskFields array('cmd', 'tag', 'desc')
#

The parts of the cron entry that define the task itself, including metadata
that is ignored by the cron daemon

The parts of the cron entry that define the task itself, including metadata that is ignored by the cron daemon

public static array $schedules array('hourly','daily','weekly','monthly','yearly')
#
public static array $schedFields array('min', 'hour', 'dayOfMonth', 'month', 'dayOfWeek')
#

The fields of the cron entry that define its schedule

The fields of the cron entry that define its schedule

X2CRM Documentation API documentation generated by ApiGen 2.8.0