PHP Класс PEAR_Config

Автор: Stig Bakken ([email protected])
Автор: Greg Beaver ([email protected])
Наследование: extends PEAR
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$_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

Открытые методы

Метод Описание
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.

Описание методов

PEAR_Config() публичный Метод

Constructor.
См. также: PEAR_Config::singleton
public PEAR_Config ( $user_file = '', $system_file = '', $ftp_file = false, $strict = true )

_addConfigVars() публичный Метод

public _addConfigVars ( $class, $vars ) : true | PEAR_Error
Результат true | PEAR_Error

_decodeInput() публичный Метод

Decodes/unscrambles configuration data after reading from files.
См. также: PEAR_Config::_encodeOutput
public _decodeInput ( &$data ) : boolean
Результат boolean TRUE on success

_encodeOutput() публичный Метод

Currently, 'password' values will be base64-encoded as to avoid that people spot cleartext passwords by accident.
public _encodeOutput ( &$data ) : boolean
Результат boolean TRUE on success

_getChannelValue() публичный Метод

Returns a channel-specific configuration value, prioritizing layers as per the layers property.
public _getChannelValue ( $key, $layer, $channel ) : mixed
Результат mixed the config value, or NULL if not found

_lazyChannelSetup() публичный Метод

public _lazyChannelSetup ( $uselayer = false )

_prependPath() публичный Метод

public _prependPath ( $path, $prepend )

_readConfigDataFrom() публичный Метод

Reads configuration data from a file and returns the parsed data in an array.
public _readConfigDataFrom ( $file ) : array
Результат array configuration data or a PEAR error on failure

_setupChannels() публичный Метод

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

apiVersion() публичный Метод

public apiVersion ( )

arrayMergeRecursive() публичный Метод

public arrayMergeRecursive ( $arr2, $arr1 ) : array
Результат array

definedBy() публичный Метод

Tells what config layer that gets to define a key.
public definedBy ( $key, $returnchannel = false ) : string | array
Результат 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 deleteChannel ( $channel )

get() публичный Метод

Returns a configuration value, prioritizing layers as per the layers property.
public get ( $key, $layer = null, $channel = false ) : mixed
Результат mixed the config value, or NULL if not found

getConfFile() публичный Метод

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

getDefaultChannel() публичный Метод

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
Результат string | false

getDefaultConfigFiles() публичный Метод

Return the default locations of user and system configuration files

getDocs() публичный Метод

Get the documentation for a config value.
public getDocs ( $key ) : string
Результат string documentation string

getFTP() публичный Метод

The ftp server is set in {@link readFTPConfigFile()}. It exists only if a remote configuration file has been specified
public getFTP ( ) : PEAR_FTP | false
Результат PEAR_FTP | false

getGroup() публичный Метод

Get the parameter group for a config key.
public getGroup ( $key ) : string
Результат string parameter group

getGroupKeys() публичный Метод

Get the list of the parameters in a group.
public getGroupKeys ( string $group ) : array
$group string parameter group
Результат array list of parameters in $group

getGroups() публичный Метод

Get the list of parameter groups.
public getGroups ( ) : array
Результат array list of parameter groups

getKeys() публичный Метод

Get all the current config keys.
public getKeys ( ) : array
Результат array simple array of config keys

getLayers() публичный Метод

Returns the layers defined (except the 'default' one)
public getLayers ( ) : array
Результат array of the defined layers

getPrompt() публичный Метод

Get the short documentation for a config value.
public getPrompt ( $key ) : string
Результат string short documentation string

getREST() публичный Метод

public getREST ( $version, $options = [] ) : PEAR_REST
Результат PEAR_REST

getRegistry() публичный Метод

public getRegistry ( $use = null ) : PEAR_Registry
Результат PEAR_Registry

getSetValues() публичный Метод

Get the list of allowed set values for a config value. Returns NULL for config values that are not sets.
public getSetValues ( $key ) : array
Результат array enumerated array of set values, or NULL if the config key is unknown or not a set

getType() публичный Метод

Get the type of a config value.
public getType ( $key ) : string
Результат string type, one of "string", "integer", "file", "directory", "set" or "password".

isDefined() публичный Метод

Tells whether a given key exists as a config value.
public isDefined ( $key ) : boolean
Результат boolean whether exists in this object

isDefinedLayer() публичный Метод

Tells whether a given config layer exists.
public isDefinedLayer ( $layer ) : boolean
Результат boolean whether exists in this object

mergeConfigFile() публичный Метод

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
Результат boolean TRUE on success or a PEAR error on failure

noRegistry() публичный Метод

public noRegistry ( )

readConfigFile() публичный Метод

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
Результат boolean TRUE on success or a PEAR error on failure

readFTPConfigFile() публичный Метод

public readFTPConfigFile ( $path ) : true | PEAR_Error
Результат true | PEAR_Error

remove() публичный Метод

Remove the a config key from a specific config layer.
public remove ( $key, $layer = 'user', $channel = null ) : boolean
Результат boolean TRUE on success, FALSE on failure

removeLayer() публичный Метод

Temporarily remove an entire config layer. USE WITH CARE!
public removeLayer ( $layer ) : boolean
Результат boolean TRUE on success, FALSE on failure

set() публичный Метод

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
Результат boolean TRUE on success, FALSE on failure

setChannels() публичный Метод

This should be set via a call to {@link PEAR_Registry::listChannels()}
public setChannels ( $channels, $merge = false ) : boolean
Результат boolean success of operation

setInstallRoot() публичный Метод

public setInstallRoot ( $root )

setRegistry() публичный Метод

This is to allow customization like the use of installroot
public setRegistry ( &$reg, $layer = 'user' ) : boolean
Результат boolean

singleton() публичный Метод

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.
См. также: PEAR_Config::PEAR_Config
public singleton ( $user_file = '', $system_file = '', $strict = true ) : object
Результат object an existing or new PEAR_Config instance

store() публичный Метод

Stores configuration data in a layer.
public store ( $layer = 'user', $data = null ) : boolean
Результат boolean TRUE on success, or PEAR error on failure

validConfiguration() публичный Метод

Determine whether any configuration files have been detected, and whether a registry object can be retrieved from this configuration.
public validConfiguration ( ) : boolean
Результат boolean

writeConfigFile() публичный Метод

Writes data into a config layer from a file.
public writeConfigFile ( $file = null, $layer = 'user', $data = null ) : boolean
Результат boolean TRUE on success or a PEAR error on failure

Описание свойств

$_channelConfigInfo публичное свойство

All other configuration values can only have a global value
public array $_channelConfigInfo
Результат array

$_channels публичное свойство

Channels that can be accessed
См. также: setChannels()
public array $_channels
Результат array

$_errorsFound публичное свойство

amount of errors found while parsing config
public int $_errorsFound
Результат integer

$_installRoot публичное свойство

This variable is used to control the directory values returned
public string|false $_installRoot
Результат string | false

$_lastError публичное свойство

public $_lastError

$_noRegistry публичное свойство

public bool $_noRegistry
Результат boolean

$_regInitialized публичное свойство

public array $_regInitialized
Результат array

$_registry публичное свойство

If requested, this will always refer to the registry contained in php_dir
public PEAR_Registry $_registry
Результат PEAR_Registry

$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').
public $configuration

$configuration_info публичное свойство

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

$files публичное свойство

Array of config files used.
public $files

$layers публичное свойство

public $layers