Zend Framework  1.12
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Zend_Config_Ini Class Reference

Public Member Functions

 __construct ($filename, $section=null, $options=false)
 Loads the section $section from the config file $filename for access facilitated by nested object properties.
 
- Public Member Functions inherited from Zend_Config
 __construct (array $array, $allowModifications=false)
 Zend_Config provides a property based interface to an array.
 
 get ($name, $default=null)
 Retrieve a value and return $default if there is no element set.
 
 __get ($name)
 Magic function so that $obj->value will work.
 
 __set ($name, $value)
 Only allow setting of a property if $allowModifications was set to true on construction.
 
 __clone ()
 Deep clone of this instance to ensure that nested Zend_Configs are also cloned.
 
 toArray ()
 Return an associative array of the stored data.
 
 __isset ($name)
 Support isset() overloading on PHP 5.1.
 
 __unset ($name)
 Support unset() overloading on PHP 5.1.
 
 count ()
 Defined by Countable interface.
 
 current ()
 Defined by Iterator interface.
 
 key ()
 Defined by Iterator interface.
 
 next ()
 Defined by Iterator interface.
 
 rewind ()
 Defined by Iterator interface.
 
 valid ()
 Defined by Iterator interface.
 
 getSectionName ()
 Returns the section name(s) loaded.
 
 areAllSectionsLoaded ()
 Returns true if all sections were loaded.
 
 merge (Zend_Config $merge)
 Merge another Zend_Config with this one.
 
 setReadOnly ()
 Prevent any more modifications being made to this instance.
 
 readOnly ()
 Returns if this Zend_Config object is read only or not.
 
 getExtends ()
 Get the current extends.
 
 setExtend ($extendingSection, $extendedSection=null)
 Set an extend for Zend_Config_Writer.
 
 _loadFileErrorHandler ($errno, $errstr, $errfile, $errline)
 Handle any errors from simplexml_load_file or parse_ini_file.
 

Protected Member Functions

 _parseIniFile ($filename)
 Load the INI file from disk using parse_ini_file().
 
 _loadIniFile ($filename)
 Load the ini file and preprocess the section separator (':' in the section name (that is used for section extension) so that the resultant array has the correct section names and the extension information is stored in a sub-key called ';extends'.
 
 _processSection ($iniArray, $section, $config=array())
 Process each element in the section and handle the ";extends" inheritance key.
 
 _processKey ($config, $key, $value)
 Assign the key's value to the property list.
 
- Protected Member Functions inherited from Zend_Config
 _assertValidExtend ($extendingSection, $extendedSection)
 Throws an exception if $extendingSection may not extend $extendedSection, and tracks the section extension if it is valid.
 
 _arrayMergeRecursive ($firstArray, $secondArray)
 Merge two arrays recursively, overwriting keys of the same name in $firstArray with the value in $secondArray.
 

Protected Attributes

 $_nestSeparator = '.'
 
 $_sectionSeparator = ':'
 
 $_skipExtends = false
 
- Protected Attributes inherited from Zend_Config
 $_allowModifications
 
 $_index
 
 $_count
 
 $_data
 
 $_skipNextIteration
 
 $_loadedSection
 
 $_extends = array()
 
 $_loadFileErrorStr = null
 

Constructor & Destructor Documentation

__construct (   $filename,
  $section = null,
  $options = false 
)

Loads the section $section from the config file $filename for access facilitated by nested object properties.

If the section name contains a ":" then the section name to the right is loaded and included into the properties. Note that the keys in this $section will override any keys of the same name in the sections that have been included via ":".

If the $section is null, then all sections in the ini file are loaded.

If any key includes a ".", then this will act as a separator to create a sub-property.

example ini file: [all] db.connection = database hostname = live

[staging : all] hostname = staging

after calling $data = new Zend_Config_Ini($file, 'staging'); then $data->hostname === "staging" $data->db->connection === "database"

The $options parameter may be provided as either a boolean or an array. If provided as a boolean, this sets the $allowModifications option of Zend_Config. If provided as an array, there are three configuration directives that may be set. For example:

$options = array( 'allowModifications' => false, 'nestSeparator' => ':', 'skipExtends' => false, );

Parameters
string$filename
mixed$section
boolean | array$options
Exceptions
Zend_Config_Exception
Returns
void
See Also
Zend_Config_Exception
Zend_Config_Exception

Member Function Documentation

_loadIniFile (   $filename)
protected

Load the ini file and preprocess the section separator (':' in the section name (that is used for section extension) so that the resultant array has the correct section names and the extension information is stored in a sub-key called ';extends'.

We use ';extends' as this can never be a valid key name in an INI file that has been loaded using parse_ini_file().

Parameters
string$filename
Exceptions
Zend_Config_Exception
Returns
array
See Also
Zend_Config_Exception
_parseIniFile (   $filename)
protected

Load the INI file from disk using parse_ini_file().

Use a private error handler to convert any loading errors into a Zend_Config_Exception

Parameters
string$filename
Exceptions
Zend_Config_Exception
Returns
array
See Also
Zend_Config_Exception
_processKey (   $config,
  $key,
  $value 
)
protected

Assign the key's value to the property list.

Handles the nest separator for sub-properties.

Parameters
array$config
string$key
string$value
Exceptions
Zend_Config_Exception
Returns
array
See Also
Zend_Config_Exception
Zend_Config_Exception
_processSection (   $iniArray,
  $section,
  $config = array() 
)
protected

Process each element in the section and handle the ";extends" inheritance key.

Passes control to _processKey() to handle the nest separator sub-property syntax that may be used within the key name.

Parameters
array$iniArray
string$section
array$config
Exceptions
Zend_Config_Exception
Returns
array
See Also
Zend_Config_Exception

Member Data Documentation

$_nestSeparator = '.'
protected
$_sectionSeparator = ':'
protected
$_skipExtends = false
protected