PHP 클래스 eZScript

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: \code $script = eZScript::instance(); $script->startup(); Read arguments and modify script accordingly $script->initialize(); Do the actual script here $script->shutdown(); // Finish execution \endcode
파일 보기 프로젝트 열기: ezsystems/ezpublish-legacy 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$DebugMessage
$ExitCode
$InitializationErrorMessage
$IsInitialized \privatesection
$IsQuiet
$ShowVerbose
$SiteAccess
$UseDebugOutput
$UseExtensions
$UseModules
$UseSession
$User

공개 메소드들

메소드 설명
__construct ( $settings = [] ) *! Constructor
currentOptionConfig ( ) *! \return the current option configuration, this will be a mix of the standard options and script specified.
currentOptions ( ) *! \return the currently set options if getOptions() has been run or \c false if no options are set.
exitCode ( )
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.
initializationError ( )
initialize ( ) *! Initializes all settings which are required for the script to run, must be called after startup() and getOptions().
instance ( array $settings = [] ) : eZScript Returns a shared instance of the eZScript class.
isInitialized ( )
isLoud ( ) *! \return \c true if output is allowed.
isQuiet ( ) *! \return \c true if output is not allowed.
iterate ( $cli, $status, $text = false )
resetIteration ( $iterationMax = false, $startIndex )
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.
setDebugMessage ( $message ) *! Sets the text message which is shown before the debug list.
setExitCode ( $code = false ) *! Sets the current exit code which will be set with an exit() call in shutdown().
setIsInitialized ( $isInitialized )
setIsQuiet ( $isQuiet ) *! Sets whether any output should be used or not.
setIterationData ( $trueString, $falseString, $numericStrings = false, $wrapNumeric = false )
setShowVerboseOutput ( $verbose ) *! Controls whether verbose output is used or not, use \c false to turn it off, \c true to turn it on or a number to select the verbose level (\c true == 1).
setUseDebugAccumulators ( $useAccumulators ) *! Sets whether accumulators should be shown on debug output or not.
setUseDebugOutput ( $useDebug ) *! Sets whether debug output should be enabled or not.
setUseDebugTimingPoints ( $useTimingPoints ) *! Sets whether timing points should be shown on debug output or not.
setUseExtensions ( $useExtensions ) *! Sets whether extension support is to be added or not.
setUseIncludeFiles ( $useIncludeFiles ) *! Sets whether include files should be shown on debug output or not.
setUseModules ( $useModules )
setUseSession ( $useSession ) *! Sets whether session is to be used or not.
setUseSiteAccess ( $siteAccess ) *! Sets the current site access to \a $siteAccess.
setUser ( $userLogin, $userPassword )
showHelp ( $useStandardOptions = false, $optionConfig = false, $optionHelp = false, $argumentConfig = false, $arguments = false )
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
startup ( ) *! Checks if the script is run in CLI mode, if not it exits with a warning.
updateDebugSettings ( $useDebug = null ) *! \static Reads settings from site.ini and passes them to eZDebug.
updateTextCodecSettings ( ) *! \static Reads settings from i18n.ini and passes them to eZTextCodec.
usedSiteAccess ( ) *! \return the currently set siteaccess or \c false if none is set.
validateVersion ( ) *! Checks if the script is run on correct eZ Publish version.
verboseOutputLevel ( ) *! \return the verbosity level for the script, will be \c false or a number in the range 1 and up.

비공개 메소드들

메소드 설명
updateSettings ( array $settings = [] ) Updates settings for current script.

메소드 상세

__construct() 공개 메소드

*! Constructor
public __construct ( $settings = [] )

currentOptionConfig() 공개 메소드

*! \return the current option configuration, this will be a mix of the standard options and script specified.
public currentOptionConfig ( )

currentOptions() 공개 메소드

*! \return the currently set options if getOptions() has been run or \c false if no options are set.
public currentOptions ( )

exitCode() 공개 메소드

public exitCode ( )

getOptions() 공개 메소드

standard options are: 'debug', 'colors', 'log', 'siteaccess', 'verbose', 'user' (false), and can be set to false to be disabled
public getOptions ( $config = '', $argumentConfig = '', $optionHelp = false, $arguments = false, $useStandardOptions = true )

initializationError() 공개 메소드

public initializationError ( )

initialize() 공개 메소드

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

instance() 정적인 공개 메소드

Returns a shared instance of the eZScript class.
static public instance ( array $settings = [] ) : eZScript
$settings array Used by the first generated instance, but ignored for subsequent calls.
리턴 eZScript

isInitialized() 공개 메소드

public isInitialized ( )

isLoud() 공개 메소드

\sa isQuiet
public isLoud ( )

isQuiet() 공개 메소드

\sa isLoud
public isQuiet ( )

iterate() 공개 메소드

public iterate ( $cli, $status, $text = false )

resetIteration() 공개 메소드

public resetIteration ( $iterationMax = false, $startIndex )

setAllowedDebugLevels() 공개 메소드

\note This requires that setUseDebugOutput is set to true or that the user has enabled debug in the arguments.
public setAllowedDebugLevels ( $allowedDebugLevels )

setDebugMessage() 공개 메소드

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.
public setDebugMessage ( $message )

setExitCode() 공개 메소드

If you don't want shutdown() to exit automatically set it to \c false.
public setExitCode ( $code = false )

setIsInitialized() 공개 메소드

public setIsInitialized ( $isInitialized )

setIsQuiet() 공개 메소드

\sa isQuiet, isLoud \note it will also call eZCLI::setIsQuiet()
public setIsQuiet ( $isQuiet )

setIterationData() 공개 메소드

public setIterationData ( $trueString, $falseString, $numericStrings = false, $wrapNumeric = false )

setShowVerboseOutput() 공개 메소드

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.
public setShowVerboseOutput ( $verbose )

setUseDebugAccumulators() 공개 메소드

\note This requires that setUseDebugOutput is set to true or that the user has enabled debug in the arguments.
public setUseDebugAccumulators ( $useAccumulators )

setUseDebugOutput() 공개 메소드

\note This can also be called by the argument parser if the user specifies to show debug.
public setUseDebugOutput ( $useDebug )

setUseDebugTimingPoints() 공개 메소드

\note This requires that setUseDebugOutput is set to true or that the user has enabled debug in the arguments.
public setUseDebugTimingPoints ( $useTimingPoints )

setUseExtensions() 공개 메소드

\note This will only work if it is set before initialized() is called.
public setUseExtensions ( $useExtensions )

setUseIncludeFiles() 공개 메소드

\note This requires that setUseDebugOutput is set to true or that the user has enabled debug in the arguments.
public setUseIncludeFiles ( $useIncludeFiles )

setUseModules() 공개 메소드

public setUseModules ( $useModules )

setUseSession() 공개 메소드

\note This will only work if it is set before initialized() is called. \note If session is enabled the current session data will be removed on shutdown().
public setUseSession ( $useSession )

setUseSiteAccess() 공개 메소드

\note This will only work if it is set before initialized() is called. \note This will be filled in if getOptions() is used and the user specifices it in the arguments.
public setUseSiteAccess ( $siteAccess )

setUser() 공개 메소드

public setUser ( $userLogin, $userPassword )

showHelp() 공개 메소드

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

shutdown() 공개 메소드

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.
public shutdown ( $exitCode = false, $exitText = false )

startup() 공개 메소드

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

updateDebugSettings() 공개 메소드

*! \static Reads settings from site.ini and passes them to eZDebug.
public updateDebugSettings ( $useDebug = null )

updateTextCodecSettings() 공개 메소드

*! \static Reads settings from i18n.ini and passes them to eZTextCodec.

usedSiteAccess() 공개 메소드

*! \return the currently set siteaccess or \c false if none is set.
public usedSiteAccess ( )

validateVersion() 공개 메소드

*! Checks if the script is run on correct eZ Publish version.
public validateVersion ( )

verboseOutputLevel() 공개 메소드

*! \return the verbosity level for the script, will be \c false or a number in the range 1 and up.
public verboseOutputLevel ( )

프로퍼티 상세

$DebugMessage 공개적으로 프로퍼티

public $DebugMessage

$ExitCode 공개적으로 프로퍼티

public $ExitCode

$InitializationErrorMessage 공개적으로 프로퍼티

public $InitializationErrorMessage

$IsInitialized 공개적으로 프로퍼티

\privatesection
public $IsInitialized

$IsQuiet 공개적으로 프로퍼티

public $IsQuiet

$ShowVerbose 공개적으로 프로퍼티

public $ShowVerbose

$SiteAccess 공개적으로 프로퍼티

public $SiteAccess

$UseDebugOutput 공개적으로 프로퍼티

public $UseDebugOutput

$UseExtensions 공개적으로 프로퍼티

public $UseExtensions

$UseModules 공개적으로 프로퍼티

public $UseModules

$UseSession 공개적으로 프로퍼티

public $UseSession

$User 공개적으로 프로퍼티

public $User