PHP Class Zend_Config

Inheritance: implements Countable, implements Iterator
Show file Open project: dbpatch/dbpatch Class Usage Examples

Protected Properties

Property Type Description
$_allowModifications boolean Whether in-memory modifications to configuration data are allowed
$_count integer Number of elements in configuration data
$_data array Contains array of configuration data
$_extends array This is used to track section inheritance. The keys are names of sections that extend other sections, and the values are the extended sections.
$_index integer Iteration index
$_loadFileErrorStr string Is null if there was no error while file loading
$_loadedSection mixed Contains which config file sections were loaded. This is null if all sections were loaded, a string name if one section is loaded and an array of string names if multiple sections were loaded.
$_skipNextIteration boolean Used when unsetting values during iteration to ensure we do not skip the next element

Public Methods

Method Description
__clone ( ) : void Deep clone of this instance to ensure that nested Zend_Configs are also cloned.
__construct ( array $array, boolean $allowModifications = false ) : void Zend_Config provides a property based interface to an array. The data are read-only unless $allowModifications is set to true on construction.
__get ( string $name ) : mixed Magic function so that $obj->value will work.
__isset ( string $name ) : boolean Support isset() overloading on PHP 5.1
__set ( string $name, mixed $value ) : void Only allow setting of a property if $allowModifications was set to true on construction. Otherwise, throw an exception.
__unset ( string $name ) : void Support unset() overloading on PHP 5.1
areAllSectionsLoaded ( ) : boolean Returns true if all sections were loaded
count ( ) : integer Defined by Countable interface
current ( ) : mixed Defined by Iterator interface
get ( string $name, mixed $default = null ) : mixed Retrieve a value and return $default if there is no element set.
getExtends ( ) : array Get the current extends
getSectionName ( ) : mixed Returns the section name(s) loaded.
key ( ) : mixed Defined by Iterator interface
merge ( Zend_Config $merge ) : Zend_Config Merge another Zend_Config with this one. The items in $merge will override the same named items in the current config.
next ( ) Defined by Iterator interface
readOnly ( ) : boolean Returns if this Zend_Config object is read only or not.
rewind ( ) Defined by Iterator interface
setExtend ( string $extendingSection, string $extendedSection = null ) : void Set an extend for Zend_Config_Writer
setReadOnly ( ) Prevent any more modifications being made to this instance. Useful after merge() has been used to merge multiple Zend_Config objects into one object which should then not be modified again.
toArray ( ) : array Return an associative array of the stored data.
valid ( ) : boolean Defined by Iterator interface

Protected Methods

Method Description
_arrayMergeRecursive ( mixed $firstArray, mixed $secondArray ) : array Merge two arrays recursively, overwriting keys of the same name in $firstArray with the value in $secondArray.
_assertValidExtend ( string $extendingSection, string $extendedSection ) : void Throws an exception if $extendingSection may not extend $extendedSection, and tracks the section extension if it is valid.
_loadFileErrorHandler ( integer $errno, string $errstr, string $errfile, integer $errline ) Handle any errors from simplexml_load_file or parse_ini_file

Method Details

__clone() public method

Deep clone of this instance to ensure that nested Zend_Configs are also cloned.
public __clone ( ) : void
return void

__construct() public method

Zend_Config also implements Countable and Iterator to facilitate easy access to the data.
public __construct ( array $array, boolean $allowModifications = false ) : void
$array array
$allowModifications boolean
return void

__get() public method

Magic function so that $obj->value will work.
public __get ( string $name ) : mixed
$name string
return mixed

__isset() public method

Support isset() overloading on PHP 5.1
public __isset ( string $name ) : boolean
$name string
return boolean

__set() public method

Only allow setting of a property if $allowModifications was set to true on construction. Otherwise, throw an exception.
public __set ( string $name, mixed $value ) : void
$name string
$value mixed
return void

__unset() public method

Support unset() overloading on PHP 5.1
public __unset ( string $name ) : void
$name string
return void

_arrayMergeRecursive() protected method

Merge two arrays recursively, overwriting keys of the same name in $firstArray with the value in $secondArray.
protected _arrayMergeRecursive ( mixed $firstArray, mixed $secondArray ) : array
$firstArray mixed First array
$secondArray mixed Second array to merge into first array
return array

_assertValidExtend() protected method

Throws an exception if $extendingSection may not extend $extendedSection, and tracks the section extension if it is valid.
protected _assertValidExtend ( string $extendingSection, string $extendedSection ) : void
$extendingSection string
$extendedSection string
return void

_loadFileErrorHandler() protected method

Handle any errors from simplexml_load_file or parse_ini_file
protected _loadFileErrorHandler ( integer $errno, string $errstr, string $errfile, integer $errline )
$errno integer
$errstr string
$errfile string
$errline integer

areAllSectionsLoaded() public method

Returns true if all sections were loaded
public areAllSectionsLoaded ( ) : boolean
return boolean

count() public method

Defined by Countable interface
public count ( ) : integer
return integer

current() public method

Defined by Iterator interface
public current ( ) : mixed
return mixed

get() public method

Retrieve a value and return $default if there is no element set.
public get ( string $name, mixed $default = null ) : mixed
$name string
$default mixed
return mixed

getExtends() public method

Get the current extends
public getExtends ( ) : array
return array

getSectionName() public method

Returns the section name(s) loaded.
public getSectionName ( ) : mixed
return mixed

key() public method

Defined by Iterator interface
public key ( ) : mixed
return mixed

merge() public method

Merge another Zend_Config with this one. The items in $merge will override the same named items in the current config.
public merge ( Zend_Config $merge ) : Zend_Config
$merge Zend_Config
return Zend_Config

next() public method

Defined by Iterator interface
public next ( )

readOnly() public method

Returns if this Zend_Config object is read only or not.
public readOnly ( ) : boolean
return boolean

rewind() public method

Defined by Iterator interface
public rewind ( )

setExtend() public method

Set an extend for Zend_Config_Writer
public setExtend ( string $extendingSection, string $extendedSection = null ) : void
$extendingSection string
$extendedSection string
return void

setReadOnly() public method

Prevent any more modifications being made to this instance. Useful after merge() has been used to merge multiple Zend_Config objects into one object which should then not be modified again.
public setReadOnly ( )

toArray() public method

Return an associative array of the stored data.
public toArray ( ) : array
return array

valid() public method

Defined by Iterator interface
public valid ( ) : boolean
return boolean

Property Details

$_allowModifications protected property

Whether in-memory modifications to configuration data are allowed
protected bool $_allowModifications
return boolean

$_count protected property

Number of elements in configuration data
protected int $_count
return integer

$_data protected property

Contains array of configuration data
protected array $_data
return array

$_extends protected property

This is used to track section inheritance. The keys are names of sections that extend other sections, and the values are the extended sections.
protected array $_extends
return array

$_index protected property

Iteration index
protected int $_index
return integer

$_loadFileErrorStr protected property

Is null if there was no error while file loading
protected string $_loadFileErrorStr
return string

$_loadedSection protected property

Contains which config file sections were loaded. This is null if all sections were loaded, a string name if one section is loaded and an array of string names if multiple sections were loaded.
protected mixed $_loadedSection
return mixed

$_skipNextIteration protected property

Used when unsetting values during iteration to ensure we do not skip the next element
protected bool $_skipNextIteration
return boolean