PHP Class PEAR_Config, newscoop

Author: Stig Bakken ([email protected])
Author: Greg Beaver ([email protected])
Inheritance: extends PEAR
Datei anzeigen Open project: sourcefabric/newscoop Class Usage Examples

Public Properties

Property Type Description
$_channelConfigInfo array All other configuration values can only have a global value
$_channels array Channels that can be accessed
$_errorsFound integer amount of errors found while parsing config
$_installRoot string | false This variable is used to control the directory values returned
$_lastError
$_noRegistry boolean
$_regInitialized array
$_registry PEAR_Registry If requested, this will always refer to the registry contained in php_dir
$configuration The order in the first dimension is important! Earlier layers will shadow later ones when a config value is requested (if a 'user' value exists, it will be returned first, then 'system' and finally 'default').
$configuration_info Information about the configuration data. Stores the type, default value and a documentation string for each configuration value.
$files Array of config files used.
$layers

Public Methods

Method Description
PEAR_Config ( $user_file = '', $system_file = '', $ftp_file = false, $strict = true ) Constructor.
_addConfigVars ( $class, $vars ) : true | PEAR_Error
_decodeInput ( &$data ) : boolean Decodes/unscrambles configuration data after reading from files.
_encodeOutput ( &$data ) : boolean Encodes/scrambles configuration data before writing to files.
_getChannelValue ( $key, $layer, $channel ) : mixed Returns a channel-specific configuration value, prioritizing layers as per the layers property.
_lazyChannelSetup ( $uselayer = false )
_prependPath ( $path, $prepend )
_readConfigDataFrom ( $file ) : array Reads configuration data from a file and returns the parsed data in an array.
_setupChannels ( ) Reads the existing configurations and creates the _channels array from it
apiVersion ( )
arrayMergeRecursive ( $arr2, $arr1 ) : array
definedBy ( $key, $returnchannel = false ) : string | array Tells what config layer that gets to define a key.
deleteChannel ( $channel )
get ( $key, $layer = null, $channel = false ) : mixed Returns a configuration value, prioritizing layers as per the layers property.
getConfFile ( string $layer ) Gets the file used for storing the config for a layer
getDefaultChannel ( $layer = null ) : string | false Retrieve the default channel.
getDefaultConfigFiles ( ) Return the default locations of user and system configuration files
getDocs ( $key ) : string Get the documentation for a config value.
getFTP ( ) : PEAR_FTP | false The ftp server is set in {@link readFTPConfigFile()}. It exists only if a remote configuration file has been specified
getGroup ( $key ) : string Get the parameter group for a config key.
getGroupKeys ( string $group ) : array Get the list of the parameters in a group.
getGroups ( ) : array Get the list of parameter groups.
getKeys ( ) : array Get all the current config keys.
getLayers ( ) : array Returns the layers defined (except the 'default' one)
getPrompt ( $key ) : string Get the short documentation for a config value.
getREST ( $version, $options = [] ) : PEAR_REST
getRegistry ( $use = null ) : PEAR_Registry
getSetValues ( $key ) : array Get the list of allowed set values for a config value. Returns NULL for config values that are not sets.
getType ( $key ) : string Get the type of a config value.
isDefined ( $key ) : boolean Tells whether a given key exists as a config value.
isDefinedLayer ( $layer ) : boolean Tells whether a given config layer exists.
mergeConfigFile ( $file, $override = true, $layer = 'user', $strict = true ) : boolean Merges data into a config layer from a file. Does the same thing as readConfigFile, except it does not replace all existing values in the config layer.
noRegistry ( )
readConfigFile ( $file = null, $layer = 'user', $strict = true ) : boolean Reads configuration data from a file. All existing values in the config layer are discarded and replaced with data from the file.
readFTPConfigFile ( $path ) : true | PEAR_Error
remove ( $key, $layer = 'user', $channel = null ) : boolean Remove the a config key from a specific config layer.
removeLayer ( $layer ) : boolean Temporarily remove an entire config layer. USE WITH CARE!
set ( $key, $value, $layer = 'user', $channel = false ) : boolean Set a config value in a specific layer (defaults to 'user').
setChannels ( $channels, $merge = false ) : boolean Set the list of channels.
setInstallRoot ( $root )
setRegistry ( &$reg, $layer = 'user' ) : boolean This is to allow customization like the use of installroot
singleton ( $user_file = '', $system_file = '', $strict = true ) : object Static singleton method. If you want to keep only one instance of this class in use, this method will give you a reference to the last created PEAR_Config object if one exists, or create a new object.
store ( $layer = 'user', $data = null ) : boolean Stores configuration data in a layer.
validConfiguration ( ) : boolean Determine whether any configuration files have been detected, and whether a registry object can be retrieved from this configuration.
writeConfigFile ( $file = null, $layer = 'user', $data = null ) : boolean Writes data into a config layer from a file.

Method Details

PEAR_Config() public method

Constructor.
See also: PEAR_Config::singleton
public PEAR_Config ( $user_file = '', $system_file = '', $ftp_file = false, $strict = true )

_addConfigVars() public method

public _addConfigVars ( $class, $vars ) : true | PEAR_Error
return true | PEAR_Error

_decodeInput() public method

Decodes/unscrambles configuration data after reading from files.
See also: PEAR_Config::_encodeOutput
public _decodeInput ( &$data ) : boolean
return boolean TRUE on success

_encodeOutput() public method

Currently, 'password' values will be base64-encoded as to avoid that people spot cleartext passwords by accident.
public _encodeOutput ( &$data ) : boolean
return boolean TRUE on success

_getChannelValue() public method

Returns a channel-specific configuration value, prioritizing layers as per the layers property.
public _getChannelValue ( $key, $layer, $channel ) : mixed
return mixed the config value, or NULL if not found

_lazyChannelSetup() public method

public _lazyChannelSetup ( $uselayer = false )

_prependPath() public method

public _prependPath ( $path, $prepend )

_readConfigDataFrom() public method

Reads configuration data from a file and returns the parsed data in an array.
public _readConfigDataFrom ( $file ) : array
return array configuration data or a PEAR error on failure

_setupChannels() public method

Reads the existing configurations and creates the _channels array from it
public _setupChannels ( )

apiVersion() public method

public apiVersion ( )

arrayMergeRecursive() public method

public arrayMergeRecursive ( $arr2, $arr1 ) : array
return array

definedBy() public method

Tells what config layer that gets to define a key.
public definedBy ( $key, $returnchannel = false ) : string | array
return string | array the config layer, or an empty string if not found. if $returnchannel, the return is an array array('layer' => layername, 'channel' => channelname), or an empty string if not found

deleteChannel() public method

public deleteChannel ( $channel )

get() public method

Returns a configuration value, prioritizing layers as per the layers property.
public get ( $key, $layer = null, $channel = false ) : mixed
return mixed the config value, or NULL if not found

getConfFile() public method

Gets the file used for storing the config for a layer
public getConfFile ( string $layer )
$layer string 'user' or 'system'

getDefaultChannel() public method

On startup, channels are not initialized, so if the default channel is not pear.php.net, then initialize the config.
public getDefaultChannel ( $layer = null ) : string | false
return string | false

getDefaultConfigFiles() public method

Return the default locations of user and system configuration files

getDocs() public method

Get the documentation for a config value.
public getDocs ( $key ) : string
return string documentation string

getFTP() public method

The ftp server is set in {@link readFTPConfigFile()}. It exists only if a remote configuration file has been specified
public getFTP ( ) : PEAR_FTP | false
return PEAR_FTP | false

getGroup() public method

Get the parameter group for a config key.
public getGroup ( $key ) : string
return string parameter group

getGroupKeys() public method

Get the list of the parameters in a group.
public getGroupKeys ( string $group ) : array
$group string parameter group
return array list of parameters in $group

getGroups() public method

Get the list of parameter groups.
public getGroups ( ) : array
return array list of parameter groups

getKeys() public method

Get all the current config keys.
public getKeys ( ) : array
return array simple array of config keys

getLayers() public method

Returns the layers defined (except the 'default' one)
public getLayers ( ) : array
return array of the defined layers

getPrompt() public method

Get the short documentation for a config value.
public getPrompt ( $key ) : string
return string short documentation string

getREST() public method

public getREST ( $version, $options = [] ) : PEAR_REST
return PEAR_REST

getRegistry() public method

public getRegistry ( $use = null ) : PEAR_Registry
return PEAR_Registry

getSetValues() public method

Get the list of allowed set values for a config value. Returns NULL for config values that are not sets.
public getSetValues ( $key ) : array
return array enumerated array of set values, or NULL if the config key is unknown or not a set

getType() public method

Get the type of a config value.
public getType ( $key ) : string
return string type, one of "string", "integer", "file", "directory", "set" or "password".

isDefined() public method

Tells whether a given key exists as a config value.
public isDefined ( $key ) : boolean
return boolean whether exists in this object

isDefinedLayer() public method

Tells whether a given config layer exists.
public isDefinedLayer ( $layer ) : boolean
return boolean whether exists in this object

mergeConfigFile() public method

Merges data into a config layer from a file. Does the same thing as readConfigFile, except it does not replace all existing values in the config layer.
public mergeConfigFile ( $file, $override = true, $layer = 'user', $strict = true ) : boolean
return boolean TRUE on success or a PEAR error on failure

noRegistry() public method

public noRegistry ( )

readConfigFile() public method

Reads configuration data from a file. All existing values in the config layer are discarded and replaced with data from the file.
public readConfigFile ( $file = null, $layer = 'user', $strict = true ) : boolean
return boolean TRUE on success or a PEAR error on failure

readFTPConfigFile() public method

public readFTPConfigFile ( $path ) : true | PEAR_Error
return true | PEAR_Error

remove() public method

Remove the a config key from a specific config layer.
public remove ( $key, $layer = 'user', $channel = null ) : boolean
return boolean TRUE on success, FALSE on failure

removeLayer() public method

Temporarily remove an entire config layer. USE WITH CARE!
public removeLayer ( $layer ) : boolean
return boolean TRUE on success, FALSE on failure

set() public method

Enforces the types defined in the configuration_info array. An integer config variable will be cast to int, and a set config variable will be validated against its legal values.
public set ( $key, $value, $layer = 'user', $channel = false ) : boolean
return boolean TRUE on success, FALSE on failure

setChannels() public method

This should be set via a call to {@link PEAR_Registry::listChannels()}
public setChannels ( $channels, $merge = false ) : boolean
return boolean success of operation

setInstallRoot() public method

public setInstallRoot ( $root )

setRegistry() public method

This is to allow customization like the use of installroot
public setRegistry ( &$reg, $layer = 'user' ) : boolean
return boolean

singleton() public method

Static singleton method. If you want to keep only one instance of this class in use, this method will give you a reference to the last created PEAR_Config object if one exists, or create a new object.
See also: PEAR_Config::PEAR_Config
public singleton ( $user_file = '', $system_file = '', $strict = true ) : object
return object an existing or new PEAR_Config instance

store() public method

Stores configuration data in a layer.
public store ( $layer = 'user', $data = null ) : boolean
return boolean TRUE on success, or PEAR error on failure

validConfiguration() public method

Determine whether any configuration files have been detected, and whether a registry object can be retrieved from this configuration.
public validConfiguration ( ) : boolean
return boolean

writeConfigFile() public method

Writes data into a config layer from a file.
public writeConfigFile ( $file = null, $layer = 'user', $data = null ) : boolean
return boolean TRUE on success or a PEAR error on failure

Property Details

$_channelConfigInfo public_oe property

All other configuration values can only have a global value
public array $_channelConfigInfo
return array

$_channels public_oe property

Channels that can be accessed
See also: setChannels()
public array $_channels
return array

$_errorsFound public_oe property

amount of errors found while parsing config
public int $_errorsFound
return integer

$_installRoot public_oe property

This variable is used to control the directory values returned
public string|false $_installRoot
return string | false

$_lastError public_oe property

public $_lastError

$_noRegistry public_oe property

public bool $_noRegistry
return boolean

$_regInitialized public_oe property

public array $_regInitialized
return array

$_registry public_oe property

If requested, this will always refer to the registry contained in php_dir
public PEAR_Registry $_registry
return PEAR_Registry

$configuration public_oe property

The order in the first dimension is important! Earlier layers will shadow later ones when a config value is requested (if a 'user' value exists, it will be returned first, then 'system' and finally 'default').
public $configuration

$configuration_info public_oe property

Information about the configuration data. Stores the type, default value and a documentation string for each configuration value.
public $configuration_info

$files public_oe property

Array of config files used.
public $files

$layers public_oe property

public $layers