eZPublish  4.7
eZScript Class Reference

Handles the basics of script execution. More...

Public Member Functions

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

Static Public Member Functions

static instance ($settings=array())
 Returns a shared instance of the eZScript class. More...
 
 updateDebugSettings ($useDebug=null)
 
 updateTextCodecSettings ()
 

Public Attributes

 $DebugMessage
 
 $ExitCode
 
 $InitializationErrorMessage
 
 $IsQuiet
 
 $ShowVerbose
 
 $SiteAccess
 
 $UseDebugOutput
 
 $UseExtensions
 
 $UseModules
 
 $User
 
 $UseSession
 

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->startup();
// Read arguments and modify script accordingly
$script->initialize();
// Do the actual script here
$script->shutdown(); // Finish execution

Member Function Documentation

eZScript::currentOptionConfig ( )
Returns
the current option configuration, this will be a mix of the standard options and script specified.
eZScript::currentOptions ( )
Returns
the currently set options if getOptions() has been run or false if no options are set.
eZScript::exitCode ( )
eZScript::eZScript (   $settings = array())

Constructor

Referenced by instance().

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

eZScript::initializationError ( )
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.

Referenced by getOptions().

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

Returns a shared instance of the eZScript class.

Parameters
array$settingsUsed by the first generated instance, but ignored for subsequent calls.
Returns
eZScript

Referenced by childHandler(), daemonSignalHandler(), and ezpContentPublishingProcess\publish().

eZScript::isInitialized ( )
eZScript::isLoud ( )
Returns
true if output is allowed.
See Also
isQuiet

Referenced by initialize().

eZScript::isQuiet ( )
Returns
true if output is not allowed.
See Also
isLoud

Referenced by initialize().

eZScript::iterate (   $cli,
  $status,
  $text = false 
)
eZScript::resetIteration (   $iterationMax = false,
  $startIndex = 0 
)
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.

Referenced by getOptions().

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.

Referenced by getOptions().

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.

eZScript::setIsQuiet (   $isQuiet)

Sets whether any output should be used or not.

See Also
isQuiet, isLoud
Note
it will also call eZCLI::setIsQuiet()

Referenced by getOptions().

eZScript::setIterationData (   $trueString,
  $falseString,
  $numericStrings = false,
  $wrapNumeric = false 
)
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.

Referenced by getOptions().

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.

Referenced by getOptions().

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.

Referenced by getOptions().

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.

Referenced by getOptions().

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.
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.

Referenced by getOptions().

eZScript::setUseModules (   $useModules)
eZScript::setUser (   $userLogin,
  $userPassword 
)

Referenced by getOptions().

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().
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.

Referenced by getOptions().

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

Referenced by getOptions().

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.

Referenced by getOptions().

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().

eZScript::updateDebugSettings (   $useDebug = null)
static

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

Referenced by initialize().

eZScript::updateTextCodecSettings ( )
static

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

Referenced by initialize().

eZScript::usedSiteAccess ( )
Returns
the currently set siteaccess or false if none is set.
eZScript::validateVersion ( )

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

eZScript::verboseOutputLevel ( )
Returns
the verbosity level for the script, will be false or a number in the range 1 and up.

Referenced by iterate().

Member Data Documentation

eZScript::$DebugMessage
eZScript::$ExitCode

Referenced by exitCode().

eZScript::$InitializationErrorMessage

Referenced by initializationError().

eZScript::$IsQuiet

Referenced by isLoud(), and isQuiet().

eZScript::$ShowVerbose

Referenced by verboseOutputLevel().

eZScript::$SiteAccess

Referenced by initialize(), and usedSiteAccess().

eZScript::$UseDebugOutput
eZScript::$UseExtensions
eZScript::$UseModules
eZScript::$User
eZScript::$UseSession

Referenced by initialize().


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