PHP 클래스 Gdn_Configuration, vanilla

상속: extends Gdn_Pluggable
파일 보기 프로젝트 열기: vanilla/vanilla 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$Data Holds the associative array of configuration data. ie. $this->_Data['Group0']['Group1']['ConfigurationName'] = 'Value';
$NotFound string

보호된 프로퍼티들

프로퍼티 타입 설명
$autoSave Whether or not to autosave this config when it is destructed.
$defaultGroup The default top level group for new configs.
$defaultPath The path to the default configuration file.
$dynamic Dynamic (writable) config source. This is the configuration source that is written to when saves or removes are occurring.
$sources Configuration Source List Associative array of Gdn_ConfigurationSource objects indexed by their respective types and source URIs. E.g: file:/path/to/config/file.php => ... string:tagname => ...
$splitting Allow dot-delimited splitting?
$useCaching Use caching to load and save configs?

공개 메소드들

메소드 설명
__construct ( string $DefaultGroup = null ) Initialize a new instance of the {@link Gdn_Configuration} class.
__destruct ( )
autoSave ( boolean $AutoSave = true )
caching ( boolean $Caching = null ) : boolean Use caching when loading/saving configs.
clearCache ( string $ConfigFile ) : void Clear cache entry for this config file.
clearSaveData ( )
defaultPath ( string $Value = null ) : string Gets or sets the path of the default configuration file.
dynamic ( ) : Gdn_ConfigurationSource Get current dynamic ConfigurationSource
find ( string $Name, boolean $Create = true ) : mixed Finds the data at a given position and returns a reference to it.
format ( $Data, array $Options = [] ) : string
get ( string $Name, mixed $DefaultValue = false ) : mixed Gets a setting from the configuration array. Returns $DefaultValue if the value isn't found.
getSortFlag ( ) : null | integer
getSource ( string $Type, string $Identifier ) : ConfigurationSource Get a reference to the internal ConfigurationSource for a given type and ID
load ( string $File, string $Name = 'Configuration', boolean $Dynamic = false ) : boolean Loads an array of settings from a file into the object with the specified name;
loadArray ( string $ConfigData, string $Tag, string $Name = 'Configuration', boolean $Dynamic = true, $SaveCallback = null, $CallbackOptions = null ) : boolean Loads settings from an array into the object with the specified name;
loadFile ( $Path, $Options = [] ) DO NOT USE, THIS IS RUBBISH
loadString ( string $String, string $Tag, string $Name = 'Configuration', boolean $Dynamic = true, $SaveCallback = null, $CallbackOptions = null ) : boolean Loads settings from a string into the object with the specified name;
massImport ( type $Data ) Import a large pre-formatted set of configs efficiently
overlayDynamic ( ) Re-apply the settings from the current dynamic config source
remove ( string $Name, $Save = true ) : boolean Removes the specified key from the specified group (if it exists).
removeFromConfig ( string | array $Name, boolean | array $Options = [] ) Remove key (or keys) from config
save ( string $File = null, string $Group = null ) : boolean Saves all settings in $Group to $File.
saveFile ( $Path, $Data, array $Options = [] )
saveToConfig ( $Name, string $Value = '', array $Options = [] ) : boolean | integer
set ( string $Name, mixed $Value, boolean $Overwrite = true, $Save = true ) Assigns a setting to the configuration array.
setSortFlag ( integer $sortFlag ) : Gdn_Configuration Set the sort flag to be used with ksort.
shutdown ( )
splitting ( boolean $Splitting = true ) Allow dot-delimited splitting on keys?

보호된 메소드들

메소드 설명
isList ( array &$list ) : boolean Determine if a given array is a list (or a hash)
mergeConfig ( array &$Data, array $Loaded ) Merge a newly loaded config into the current active state

메소드 상세

__construct() 공개 메소드

Initialize a new instance of the {@link Gdn_Configuration} class.
public __construct ( string $DefaultGroup = null )
$DefaultGroup string

__destruct() 공개 메소드

public __destruct ( )

autoSave() 공개 메소드

public autoSave ( boolean $AutoSave = true )
$AutoSave boolean

caching() 공개 메소드

Use caching when loading/saving configs.
public caching ( boolean $Caching = null ) : boolean
$Caching boolean Whether to use caching.
리턴 boolean

clearCache() 공개 메소드

Clear cache entry for this config file.
public clearCache ( string $ConfigFile ) : void
$ConfigFile string
리턴 void

clearSaveData() 공개 메소드

public clearSaveData ( )

defaultPath() 공개 메소드

Gets or sets the path of the default configuration file.
부터: 2.3
public defaultPath ( string $Value = null ) : string
$Value string Pass a value to set a new default config path.
리턴 string Returns the current default config path.

dynamic() 공개 메소드

Get current dynamic ConfigurationSource
public dynamic ( ) : Gdn_ConfigurationSource
리턴 Gdn_ConfigurationSource

find() 공개 메소드

Finds the data at a given position and returns a reference to it.
public find ( string $Name, boolean $Create = true ) : mixed
$Name string The name of the configuration using dot notation.
$Create boolean Whether or not to create the data if it isn't there already.
리턴 mixed A reference to the configuration data node.

format() 공개 정적인 메소드

public static format ( $Data, array $Options = [] ) : string
$Data
$Options array
리턴 string

get() 공개 메소드

Gets a setting from the configuration array. Returns $DefaultValue if the value isn't found.
public get ( string $Name, mixed $DefaultValue = false ) : mixed
$Name string The name of the configuration setting to get. If the setting is contained within an associative array, use dot denomination to get the setting. ie. $this->Get('Database.Host') would retrieve $Configuration[$Group]['Database']['Host'].
$DefaultValue mixed If the parameter is not found in the group, this value will be returned.
리턴 mixed The configuration value.

getSortFlag() 공개 메소드

public getSortFlag ( ) : null | integer
리턴 null | integer The sort flag to be used with ksort.

getSource() 공개 메소드

Get a reference to the internal ConfigurationSource for a given type and ID
public getSource ( string $Type, string $Identifier ) : ConfigurationSource
$Type string 'file' or 'string'
$Identifier string filename or string tag
리턴 ConfigurationSource

isList() 보호된 정적인 메소드

Determine if a given array is a list (or a hash)
protected static isList ( array &$list ) : boolean
$list array
리턴 boolean

load() 공개 메소드

Loads an array of settings from a file into the object with the specified name;
public load ( string $File, string $Name = 'Configuration', boolean $Dynamic = false ) : boolean
$File string A string containing the path to a file that contains the settings array.
$Name string The name of the variable and initial group settings. Note: When $Name is 'Configuration' then the data will be set to the root of the config.
$Dynamic boolean Optional, whether to treat this as the request's "dynamic" config, and to save config changes here. These settings will also be re-applied later when "OverlayDynamic" is called after all defaults are loaded.
리턴 boolean

loadArray() 공개 메소드

This array should be a hierarchical Vanilla config.
public loadArray ( string $ConfigData, string $Tag, string $Name = 'Configuration', boolean $Dynamic = true, $SaveCallback = null, $CallbackOptions = null ) : boolean
$ConfigData string An array containing the configuration data
$Tag string A string descriptor of this config set
$Name string The name of the variable and initial group settings. Note: When $Name is 'Configuration' then the data will be set to the root of the config.
$Dynamic boolean Optional, whether to treat this as the request's "dynamic" config, and to save config changes here. These settings will also be re-applied later when "OverlayDynamic" is called after all defaults are loaded.
리턴 boolean

loadFile() 공개 정적인 메소드

DO NOT USE, THIS IS RUBBISH
사용 중단:
public static loadFile ( $Path, $Options = [] )

loadString() 공개 메소드

This string should be a textual representation of a PHP config array, ready to be eval()'d.
public loadString ( string $String, string $Tag, string $Name = 'Configuration', boolean $Dynamic = true, $SaveCallback = null, $CallbackOptions = null ) : boolean
$String string A string containing the php settings array.
$Tag string A string descriptor of this config set
$Name string The name of the variable and initial group settings. Note: When $Name is 'Configuration' then the data will be set to the root of the config.
$Dynamic boolean Optional, whether to treat this as the request's "dynamic" config, and to save config changes here. These settings will also be re-applied later when "OverlayDynamic" is called after all defaults are loaded.
리턴 boolean

massImport() 공개 메소드

NOTE: ONLY WORKS WHEN SPLITTING IS OFF!
public massImport ( type $Data )
$Data type

mergeConfig() 보호된 정적인 메소드

Recursively
protected static mergeConfig ( array &$Data, array $Loaded )
$Data array Reference to the current active state
$Loaded array Data to merge

overlayDynamic() 공개 메소드

It may be necessary to load some default configs after loading the client config. These defaults may be overridden in the client's initial config, so that will need to be re-applied once the correct defaults are included. This method does that
public overlayDynamic ( )

remove() 공개 메소드

Returns false if the key is not found for removal, true otherwise.
public remove ( string $Name, $Save = true ) : boolean
$Name string The name of the configuration setting with dot notation.
리턴 boolean Wether or not the key was found.

removeFromConfig() 공개 메소드

Remove key (or keys) from config
public removeFromConfig ( string | array $Name, boolean | array $Options = [] )
$Name string | array Key name, or assoc array of keys to unset
$Options boolean | array Bool = whether to save or not. Assoc array = Save => Whether to save or not

save() 공개 메소드

Saves all settings in $Group to $File.
public save ( string $File = null, string $Group = null ) : boolean
$File string The full path to the file where the Settings should be saved.
$Group string The name of the settings group to be saved to the $File.
리턴 boolean

saveFile() 공개 정적인 메소드

public static saveFile ( $Path, $Data, array $Options = [] )
$Path
$Data
$Options array

saveToConfig() 공개 메소드

public saveToConfig ( $Name, string $Value = '', array $Options = [] ) : boolean | integer
$Name
$Value string
$Options array
리턴 boolean | integer

set() 공개 메소드

Assigns a setting to the configuration array.
public set ( string $Name, mixed $Value, boolean $Overwrite = true, $Save = true )
$Name string The name of the configuration setting to assign. If the setting is contained within an associative array, use dot denomination to get the setting. ie. $this->Set('Database.Host', $Value) would set $Configuration[$Group]['Database']['Host'] = $Value
$Value mixed The value of the configuration setting.
$Overwrite boolean If the setting already exists, should it's value be overwritten? Defaults to true.

setSortFlag() 공개 메소드

Set the sort flag to be used with ksort.
public setSortFlag ( integer $sortFlag ) : Gdn_Configuration
$sortFlag integer As defined in php standard definitions
리턴 Gdn_Configuration $this

shutdown() 공개 메소드

public shutdown ( )

splitting() 공개 메소드

Allow dot-delimited splitting on keys?
public splitting ( boolean $Splitting = true )
$Splitting boolean

프로퍼티 상세

$Data 공개적으로 프로퍼티

Holds the associative array of configuration data. ie. $this->_Data['Group0']['Group1']['ConfigurationName'] = 'Value';
public $Data

$NotFound 공개적으로 프로퍼티

public string $NotFound
리턴 string

$autoSave 보호되어 있는 프로퍼티

Whether or not to autosave this config when it is destructed.
protected $autoSave

$defaultGroup 보호되어 있는 프로퍼티

The default top level group for new configs.
protected $defaultGroup

$defaultPath 보호되어 있는 프로퍼티

The path to the default configuration file.
protected $defaultPath

$dynamic 보호되어 있는 프로퍼티

Dynamic (writable) config source. This is the configuration source that is written to when saves or removes are occurring.
protected $dynamic

$sources 보호되어 있는 프로퍼티

Configuration Source List Associative array of Gdn_ConfigurationSource objects indexed by their respective types and source URIs. E.g: file:/path/to/config/file.php => ... string:tagname => ...
protected $sources

$splitting 보호되어 있는 프로퍼티

Allow dot-delimited splitting?
protected $splitting

$useCaching 보호되어 있는 프로퍼티

Use caching to load and save configs?
protected $useCaching