Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

Public Member Functions | Static Public Member Functions | Public Attributes | Private Member Functions | List of all members
eZScript Class Reference

Handles the basics of script execution. More...

## Public Member Functions
| __construct ( $settings=array())
| validateVersion ()
| startup ()
| initialize ()
| isInitialized ()
| setIsInitialized ( $isInitialized)
| initializationError ()
| shutdown ( $exitCode=false, $exitText=false)
| setDebugMessage ( $message)
| setUseDebugOutput ( $useDebug)
| setUseDebugAccumulators ( $useAccumulators)
| setUseDebugTimingPoints ( $useTimingPoints)
| setUseIncludeFiles ( $useIncludeFiles)
| setAllowedDebugLevels ( $allowedDebugLevels)
| setUseSession ( $useSession)
| setUseExtensions ( $useExtensions)
| setUseSiteAccess ( $siteAccess)
| usedSiteAccess ()
| setUseModules ( $useModules)
| setUser ( $userLogin, $userPassword)
| setShowVerboseOutput ( $verbose)
| verboseOutputLevel ()
| currentOptions ()
| currentOptionConfig ()
| setExitCode ( $code=false)
| exitCode ()
| setIsQuiet ( $isQuiet)
| isQuiet ()
| isLoud ()
| setIterationData ( $trueString, $falseString, $numericStrings=false, $wrapNumeric=false)
| resetIteration ( $iterationMax=false, $startIndex=0)
| iterate ( $cli, $status, $text=false)
| showHelp ( $useStandardOptions=false, $optionConfig=false, $optionHelp=false, $argumentConfig=false, $arguments=false)
| getOptions ( $config='', $argumentConfig='', $optionHelp=false, $arguments=false, $useStandardOptions=true)

## Static Public Member Functions
static | instance ( $settings=array())
| updateDebugSettings ( $useDebug=null)
| updateTextCodecSettings ()

## Public Attributes
| $CurrentOptions
| $CurrentOptionConfig
| $CurrentStandardOptions
| $CurrentExcludeOptions
| $CurrentOptionHelp
| $IterationTrueString
| $IterationFalseString
| $IterationNumericStrings
| $IterationWrapNumeric
| $IterationIndex
| $IterationColumn
| $IterationColumnMax
| $IterationMax
| $AllowedDebugLevels
| $UseDebugAccumulators
| $UseDebugTimingPoints
| $UseIncludeFiles
| $Description
| $MinVersion
| $MaxVersion
| $ArgumentConfig
| $IsInitialized
| $InitializationErrorMessage
| $DebugMessage
| $UseDebugOutput
| $UseSession
| $UseExtensions
| $UseModules
| $User
| $SiteAccess
| $ExitCode
| $IsQuiet
| $ShowVerbose

## Private Member Functions
| updateSettings (array $settings=array())

## Detailed Description

Handles the basics of script execution.

By using this class for script execution startup, initializing and shutdown the amount code required to write a new script is reduced significantly.

It is also recommended to use the eZCLI class in addition to this class.

What this class will handle is:

- Startup of database
- Startup/shutdown of session
- Debug initialize and display
- Text codec initialize

This class consists of the static functions startup(), initialize() and shutdown().

A typical usage:

$script = eZScript::instance();
$script->startup();
// Read arguments and modify script accordingly
$script->initialize();
// Do the actual script here
$script->shutdown(); // Finish execution
eZScript\instance
static instance( $settings=array())
Definition: ezscript.php:1124

Definition at line 48 of file ezscript.php.

## Constructor & Destructor Documentation

## ◆ __construct()

eZScript::__construct | ( |  | $settings = `array()` | ) |

Parameters

  array | $settings |

Definition at line 74 of file ezscript.php.

References updateSettings().

## Member Function Documentation

## ◆ currentOptionConfig()

eZScript::currentOptionConfig | ( |  | ) |

Returns
  the current option configuration, this will be a mix of the standard options and script specified.

Definition at line 582 of file ezscript.php.

References $CurrentOptionConfig.

## ◆ currentOptions()

eZScript::currentOptions | ( |  | ) |

Returns
  the currently set options if getOptions() has been run or `false` if no options are set.

Definition at line 574 of file ezscript.php.

References $CurrentOptions.

## ◆ exitCode()

eZScript::exitCode | ( |  | ) |

Definition at line 596 of file ezscript.php.

References $ExitCode.

## ◆ getOptions()

eZScript::getOptions | ( |  | $config = `''`,
|  |  | $argumentConfig = `''`,
|  |  | $optionHelp = `false`,
|  |  | $arguments = `false`,
|  |  | $useStandardOptions = `true`
| ) |  |

Parse command line into options array. If stanadrd options are in use, carry out the associated task (eg. switch siteaccess ir logged-in user) /param $config see ezcli::parseOptionString /param $argumentConfig see ezcli::getOptions (unused for now) /param $optionHelp string echoed to screen when script invoked with -h/–help /param $arguments array of arguments. If false, command line is parsed automatically /param $useStandardOptions true or an array of standard options to be used. standard options are: 'debug', 'colors', 'log', 'siteaccess', 'verbose', 'user' (false), and can be set to false to be disabled

Definition at line 910 of file ezscript.php.

References initialize(), eZCLI\instance(), eZDebug\LEVEL_DEBUG, eZDebug\LEVEL_ERROR, eZDebug\LEVEL_NOTICE, eZDebug\LEVEL_STRICT, eZDebug\LEVEL_TIMING_POINT, eZDebug\LEVEL_WARNING, eZCLI\parseOptionString(), setAllowedDebugLevels(), setDebugMessage(), setIsQuiet(), setShowVerboseOutput(), setUseDebugAccumulators(), setUseDebugOutput(), setUseDebugTimingPoints(), setUseIncludeFiles(), setUser(), setUseSiteAccess(), showHelp(), and shutdown().

## ◆ initializationError()

eZScript::initializationError | ( |  | ) |

Definition at line 380 of file ezscript.php.

References $InitializationErrorMessage.

## ◆ initialize()

eZScript::initialize | ( |  | ) |

Initializes all settings which are required for the script to run, must be called after startup() and getOptions().

If you modify the eZScript object using the set* functions you must make sure that is done before this function is called.

Definition at line 257 of file ezscript.php.

References $SiteAccess, $UseSession, eZExtension\activateExtensions(), eZModule\activeModuleRepositories(), eZExecution\addCleanupHandler(), eZExecution\addFatalErrorHandler(), eZSys\cacheDirectory(), eZSiteAccess\change(), eZExecution\cleanup(), eZDebug\HANDLE_FROM_PHP, eZDB\instance(), eZCLI\instance(), isLoud(), isQuiet(), eZUser\loginUser(), eZExecution\setCleanExit(), eZModule\setGlobalPathList(), eZDebug\setHandleType(), setIsInitialized(), eZCodePage\setPermissionSetting(), eZSiteAccess\TYPE_DEFAULT, eZSiteAccess\TYPE_STATIC, updateDebugSettings(), and updateTextCodecSettings().

Referenced by getOptions().

## ◆ instance()

static eZScript::instance | ( |  | $settings = `array()` | ) |
| static

Returns a shared instance of the eZScript class.

Parameters

  array | $settings | Used by the first generated instance, but ignored for subsequent calls.

Returns
  eZScript

Definition at line 1124 of file ezscript.php.

## ◆ isInitialized()

eZScript::isInitialized | ( |  | ) |

Definition at line 370 of file ezscript.php.

References $IsInitialized.

## ◆ isLoud()

eZScript::isLoud | ( |  | ) |

Returns
  `true` if output is allowed.

See also
  isQuiet

Definition at line 626 of file ezscript.php.

References $IsQuiet.

Referenced by initialize().

## ◆ isQuiet()

eZScript::isQuiet | ( |  | ) |

Returns
  `true` if output is not allowed.

See also
  isLoud

Definition at line 617 of file ezscript.php.

References $IsQuiet.

Referenced by initialize().

## ◆ iterate()

eZScript::iterate | ( |  | $cli,
|  |  | $status,
|  |  | $text = `false`
| ) |  |

Definition at line 647 of file ezscript.php.

References $IterationColumn, $IterationFalseString, $IterationIndex, and verboseOutputLevel().

## ◆ resetIteration()

eZScript::resetIteration | ( |  | $iterationMax = `false`,
|  |  | $startIndex = `0`
| ) |  |

Definition at line 640 of file ezscript.php.

## ◆ setAllowedDebugLevels()

eZScript::setAllowedDebugLevels | ( |  | $allowedDebugLevels | ) |

Sets which debug levels are to be shown on debug output, this must be an array with EZ_LEVEL_* definitions taken from eZDebug.

Note
  This requires that setUseDebugOutput is set to true or that the user has enabled debug in the arguments.

Definition at line 497 of file ezscript.php.

Referenced by getOptions().

## ◆ setDebugMessage()

eZScript::setDebugMessage | ( |  | $message | ) |

Sets the text message which is shown before the debug list. There will be a default message which should suit most scripts.

Note
  This requires that setUseDebugOutput is set to true or that the user has enabled debug in the arguments.

Definition at line 447 of file ezscript.php.

Referenced by getOptions().

## ◆ setExitCode()

eZScript::setExitCode | ( |  | $code = `false` | ) |

Sets the current exit code which will be set with an exit() call in shutdown(). If you don't want shutdown() to exit automatically set it to `false`.

Definition at line 591 of file ezscript.php.

## ◆ setIsInitialized()

eZScript::setIsInitialized | ( |  | $isInitialized | ) |

Definition at line 375 of file ezscript.php.

Referenced by initialize(), and shutdown().

## ◆ setIsQuiet()

eZScript::setIsQuiet | ( |  | $isQuiet | ) |

Sets whether any output should be used or not.

See also
  isQuiet, isLoud

Note
  it will also call eZCLI::setIsQuiet()

Definition at line 606 of file ezscript.php.

References eZCLI\instance().

Referenced by getOptions().

## ◆ setIterationData()

eZScript::setIterationData | ( |  | $trueString,
|  |  | $falseString,
|  |  | $numericStrings = `false`,
|  |  | $wrapNumeric = `false`
| ) |  |

Definition at line 631 of file ezscript.php.

## ◆ setShowVerboseOutput()

eZScript::setShowVerboseOutput | ( |  | $verbose | ) |

Controls whether verbose output is used or not, use `false` to turn it off, `true` to turn it on or a number to select the verbose level (`true` == 1). The actual behaviour of verbose output depends on the script, however enabling it will make sure iteration looping displays the iteration name instead of a dot.

Definition at line 556 of file ezscript.php.

Referenced by getOptions().

## ◆ setUseDebugAccumulators()

eZScript::setUseDebugAccumulators | ( |  | $useAccumulators | ) |

Sets whether accumulators should be shown on debug output or not.

Note
  This requires that setUseDebugOutput is set to true or that the user has enabled debug in the arguments.

Definition at line 466 of file ezscript.php.

Referenced by getOptions().

## ◆ setUseDebugOutput()

eZScript::setUseDebugOutput | ( |  | $useDebug | ) |

Sets whether debug output should be enabled or not.

Note
  This can also be called by the argument parser if the user specifies to show debug.

Definition at line 456 of file ezscript.php.

Referenced by getOptions().

## ◆ setUseDebugTimingPoints()

eZScript::setUseDebugTimingPoints | ( |  | $useTimingPoints | ) |

Sets whether timing points should be shown on debug output or not.

Note
  This requires that setUseDebugOutput is set to true or that the user has enabled debug in the arguments.

Definition at line 476 of file ezscript.php.

Referenced by getOptions().

## ◆ setUseExtensions()

eZScript::setUseExtensions | ( |  | $useExtensions | ) |

Sets whether extension support is to be added or not.

Note
  This will only work if it is set before initialized() is called.

Definition at line 516 of file ezscript.php.

## ◆ setUseIncludeFiles()

eZScript::setUseIncludeFiles | ( |  | $useIncludeFiles | ) |

Sets whether include files should be shown on debug output or not.

Note
  This requires that setUseDebugOutput is set to true or that the user has enabled debug in the arguments.

Definition at line 486 of file ezscript.php.

Referenced by getOptions().

## ◆ setUseModules()

eZScript::setUseModules | ( |  | $useModules | ) |

Definition at line 539 of file ezscript.php.

## ◆ setUser()

eZScript::setUser | ( |  | $userLogin,
|  |  | $userPassword
| ) |  |

Definition at line 544 of file ezscript.php.

Referenced by getOptions().

## ◆ setUseSession()

eZScript::setUseSession | ( |  | $useSession | ) |

Sets whether session is to be used or not.

Note
  This will only work if it is set before initialized() is called.
  If session is enabled the current session data will be removed on shutdown().

Definition at line 507 of file ezscript.php.

## ◆ setUseSiteAccess()

eZScript::setUseSiteAccess | ( |  | $siteAccess | ) |

Sets the current site access to $siteAccess.

Note
  This will only work if it is set before initialized() is called.
  This will be filled in if getOptions() is used and the user specifices it in the arguments.

Definition at line 526 of file ezscript.php.

Referenced by getOptions().

## ◆ showHelp()

eZScript::showHelp | ( |  | $useStandardOptions = `false`,
|  |  | $optionConfig = `false`,
|  |  | $optionHelp = `false`,
|  |  | $argumentConfig = `false`,
|  |  | $arguments = `false`
| ) |  |

Definition at line 724 of file ezscript.php.

References $ArgumentConfig, $CurrentOptionConfig, $CurrentOptionHelp, $CurrentStandardOptions, $Description, and eZCLI\instance().

Referenced by getOptions().

## ◆ shutdown()

eZScript::shutdown | ( |  | $exitCode = `false`,
|  |  | $exitText = `false`
| ) |  |

Shuts down the currently running script, the following things will be done:

- Remove current session (if sessions are used)
- Print debug messages (if debug is enabled)
- Call cleanup function using eZExecution
- Sets the clean exit flag, that way an exit, die or other stops will not issue an error

If an exit code is set, PHP will exit with that code set (this means that this function never returns), otherwise this function returns normally.

Definition at line 395 of file ezscript.php.

References eZDB\checkTransactionCounter(), eZExecution\cleanup(), eZDB\hasInstance(), eZDB\instance(), eZCLI\instance(), eZDebug\isDebugEnabled(), eZUser\logoutCurrent(), eZDebug\printReport(), eZExecution\setCleanExit(), and setIsInitialized().

Referenced by getOptions().

## ◆ startup()

eZScript::startup | ( |  | ) |

Checks if the script is run in CLI mode, if not it exits with a warning. The PHP local is also initialized if it is used.

Call this at the very start of your script and always before getOptions() and initialize().

Definition at line 207 of file ezscript.php.

References eZDebug\HANDLE_TO_PHP, eZCLI\instance(), and eZDebug\setHandleType().

## ◆ updateDebugSettings()

eZScript::updateDebugSettings | ( |  | $useDebug = `null` | ) |
| static

Reads settings from site.ini and passes them to eZDebug.

Definition at line 1145 of file ezscript.php.

References eZCLI\instance(), eZDebug\LEVEL_DEBUG, eZDebug\LEVEL_ERROR, eZDebug\LEVEL_NOTICE, eZDebug\LEVEL_STRICT, eZDebug\LEVEL_WARNING, and eZDebug\updateSettings().

Referenced by initialize().

## ◆ updateSettings()

eZScript::updateSettings | ( | array | $settings = `array()` | ) |
| private

Updates settings for current script.

Valid keys for $settings are :

- use-session
- use-modules
- use-extensions
- user
- site-access
- description
- min_version
- max_version
- debug-message
- debug-output
- debug-levels
- debug-accumulator
- debug-timing
- debug-include

Parameters

  array | $settings |

Definition at line 135 of file ezscript.php.

Referenced by __construct().

## ◆ updateTextCodecSettings()

eZScript::updateTextCodecSettings | ( |  | ) |
| static

Reads settings from i18n.ini and passes them to eZTextCodec.

Definition at line 1184 of file ezscript.php.

References eZTextCodec\updateSettings().

Referenced by initialize().

## ◆ usedSiteAccess()

eZScript::usedSiteAccess | ( |  | ) |

Returns
  the currently set siteaccess or `false` if none is set.

Definition at line 534 of file ezscript.php.

References $SiteAccess.

## ◆ validateVersion()

eZScript::validateVersion | ( |  | ) |

Checks if the script is run on correct eZ Publish version.

Definition at line 170 of file ezscript.php.

## ◆ verboseOutputLevel()

eZScript::verboseOutputLevel | ( |  | ) |

Returns
  the verbosity level for the script, will be `false` or a number in the range 1 and up.

Definition at line 566 of file ezscript.php.

References $ShowVerbose.

Referenced by iterate().

## Member Data Documentation

## ◆ $AllowedDebugLevels

eZScript::$AllowedDebugLevels

Definition at line 63 of file ezscript.php.

## ◆ $ArgumentConfig

eZScript::$ArgumentConfig

Definition at line 70 of file ezscript.php.

Referenced by showHelp().

## ◆ $CurrentExcludeOptions

eZScript::$CurrentExcludeOptions

Definition at line 53 of file ezscript.php.

## ◆ $CurrentOptionConfig

eZScript::$CurrentOptionConfig

Definition at line 51 of file ezscript.php.

Referenced by currentOptionConfig(), and showHelp().

## ◆ $CurrentOptionHelp

eZScript::$CurrentOptionHelp

Definition at line 54 of file ezscript.php.

Referenced by showHelp().

## ◆ $CurrentOptions

eZScript::$CurrentOptions

Definition at line 50 of file ezscript.php.

Referenced by currentOptions().

## ◆ $CurrentStandardOptions

eZScript::$CurrentStandardOptions

Definition at line 52 of file ezscript.php.

Referenced by showHelp().

## ◆ $DebugMessage

eZScript::$DebugMessage

Definition at line 1197 of file ezscript.php.

## ◆ $Description

eZScript::$Description

Definition at line 67 of file ezscript.php.

Referenced by showHelp().

## ◆ $ExitCode

eZScript::$ExitCode

Definition at line 1204 of file ezscript.php.

Referenced by exitCode().

## ◆ $InitializationErrorMessage

eZScript::$InitializationErrorMessage

Definition at line 1196 of file ezscript.php.

Referenced by initializationError().

## ◆ $IsInitialized

eZScript::$IsInitialized

Definition at line 1195 of file ezscript.php.

Referenced by isInitialized().

## ◆ $IsQuiet

eZScript::$IsQuiet

Definition at line 1205 of file ezscript.php.

Referenced by isLoud(), and isQuiet().

## ◆ $IterationColumn

eZScript::$IterationColumn

Definition at line 60 of file ezscript.php.

Referenced by iterate().

## ◆ $IterationColumnMax

eZScript::$IterationColumnMax

Definition at line 61 of file ezscript.php.

## ◆ $IterationFalseString

eZScript::$IterationFalseString

Definition at line 56 of file ezscript.php.

Referenced by iterate().

## ◆ $IterationIndex

eZScript::$IterationIndex

Definition at line 59 of file ezscript.php.

Referenced by iterate().

## ◆ $IterationMax

eZScript::$IterationMax

Definition at line 62 of file ezscript.php.

## ◆ $IterationNumericStrings

eZScript::$IterationNumericStrings

Definition at line 57 of file ezscript.php.

## ◆ $IterationTrueString

eZScript::$IterationTrueString

Definition at line 55 of file ezscript.php.

## ◆ $IterationWrapNumeric

eZScript::$IterationWrapNumeric

Definition at line 58 of file ezscript.php.

## ◆ $MaxVersion

eZScript::$MaxVersion

Definition at line 69 of file ezscript.php.

## ◆ $MinVersion

eZScript::$MinVersion

Definition at line 68 of file ezscript.php.

## ◆ $ShowVerbose

eZScript::$ShowVerbose

Definition at line 1206 of file ezscript.php.

Referenced by verboseOutputLevel().

## ◆ $SiteAccess

eZScript::$SiteAccess

Definition at line 1203 of file ezscript.php.

Referenced by initialize(), and usedSiteAccess().

## ◆ $UseDebugAccumulators

eZScript::$UseDebugAccumulators

Definition at line 64 of file ezscript.php.

## ◆ $UseDebugOutput

eZScript::$UseDebugOutput

Definition at line 1198 of file ezscript.php.

## ◆ $UseDebugTimingPoints

eZScript::$UseDebugTimingPoints

Definition at line 65 of file ezscript.php.

## ◆ $UseExtensions

eZScript::$UseExtensions

Definition at line 1200 of file ezscript.php.

## ◆ $UseIncludeFiles

eZScript::$UseIncludeFiles

Definition at line 66 of file ezscript.php.

## ◆ $UseModules

eZScript::$UseModules

Definition at line 1201 of file ezscript.php.

## ◆ $User

eZScript::$User

Definition at line 1202 of file ezscript.php.

## ◆ $UseSession

eZScript::$UseSession

Definition at line 1199 of file ezscript.php.

Referenced by initialize().

The documentation for this class was generated from the following file:

- ezscript.php

Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.