Detailed Description

InifileConfiguration reads the application configuration from ini files.

Note
This class only supports ini files with sections.
Author
ingo herwig ingo@.nosp@m.wemo.nosp@m.ve.co.nosp@m.m

Definition at line 30 of file InifileConfiguration.php.

+ Inheritance diagram for InifileConfiguration:

Public Member Functions

 __construct ($configPath)
 
 getConfigPath ()
 
 getConfigurations ()
 
 addConfiguration ($name, $processValues=true)
 
 getSections ()
 
 hasSection ($section)
 
 getSection ($section, $includeMeta=false)
 
 hasValue ($key, $section)
 
 getValue ($key, $section)
 
 getBooleanValue ($key, $section)
 
 getDirectoryValue ($key, $section)
 
 getFileValue ($key, $section)
 
 getKey ($value, $section)
 
 isEditable ($section)
 
 isModified ()
 
 createSection ($section)
 
 removeSection ($section)
 
 renameSection ($oldname, $newname)
 
 setValue ($key, $value, $section, $createSection=true)
 
 removeKey ($key, $section)
 
 renameKey ($oldname, $newname, $section)
 
 writeConfiguration ($name)
 

Protected Member Functions

 processFile ($filename, $configArray=[], $parsedFiles=[])
 
 parseIniFile ($filename)
 
 processValues ()
 
 processValue (&$value)
 
 configMerge ($array1, $array2, $override)
 
 getConfigIncludes ($array)
 
 serialize ()
 
 unserialize ($parsedFiles)
 
 getSerializeFilename ($parsedFiles)
 
 checkFileDate ($fileList, $referenceFile)
 
 configChanged ()
 
 buildLookupTable ()
 
 lookup ($section, $key=null)
 

Constructor & Destructor Documentation

__construct (   $configPath)

Constructor.

Parameters
$configPathThe path, either absolute or relative to the executed script

Definition at line 54 of file InifileConfiguration.php.

Member Function Documentation

getConfigPath ( )

Get the file system path to the configuration files.

Returns
The path, either absolute or relative to the executed script

Definition at line 66 of file InifileConfiguration.php.

getConfigurations ( )

Configuration interface.

See also
Configuration::getConfigurations()

Implements Configuration.

Definition at line 77 of file InifileConfiguration.php.

addConfiguration (   $name,
  $processValues = true 
)
See also
Configuration::addConfiguration() Name is the ini file to be parsed (relative to configPath)
Note
ini files referenced in section 'config' key 'include' are parsed afterwards

Implements Configuration.

Definition at line 86 of file InifileConfiguration.php.

processFile (   $filename,
  $configArray = [],
  $parsedFiles = [] 
)
protected

Process the given file recursively.

Parameters
$filenameThe filename
$configArrayConfiguration array
$parsedFilesParsed files
Returns
Associative array with keys 'config' (configuration array) and 'files' (array of parsed files)

Definition at line 157 of file InifileConfiguration.php.

getSections ( )
See also
Configuration::getSections()

Implements Configuration.

Definition at line 184 of file InifileConfiguration.php.

hasSection (   $section)
See also
Configuration::hasSection()

Implements Configuration.

Definition at line 191 of file InifileConfiguration.php.

getSection (   $section,
  $includeMeta = false 
)
See also
Configuration::getSection()

Implements Configuration.

Definition at line 198 of file InifileConfiguration.php.

hasValue (   $key,
  $section 
)
See also
Configuration::hasValue()

Implements Configuration.

Definition at line 218 of file InifileConfiguration.php.

getValue (   $key,
  $section 
)
See also
Configuration::getValue()

Implements Configuration.

Definition at line 225 of file InifileConfiguration.php.

getBooleanValue (   $key,
  $section 
)
See also
Configuration::getBooleanValue()

Implements Configuration.

Definition at line 238 of file InifileConfiguration.php.

getDirectoryValue (   $key,
  $section 
)
See also
Configuration::getDirectoryValue()

Implements Configuration.

Definition at line 246 of file InifileConfiguration.php.

getFileValue (   $key,
  $section 
)
See also
Configuration::getFileValue()

Implements Configuration.

Definition at line 263 of file InifileConfiguration.php.

getKey (   $value,
  $section 
)
See also
Configuration::getKey()

Implements Configuration.

Definition at line 280 of file InifileConfiguration.php.

isEditable (   $section)
isModified ( )
createSection (   $section)
removeSection (   $section)
renameSection (   $oldname,
  $newname 
)
setValue (   $key,
  $value,
  $section,
  $createSection = true 
)
removeKey (   $key,
  $section 
)
renameKey (   $oldname,
  $newname,
  $section 
)
writeConfiguration (   $name)
parseIniFile (   $filename)
protected

Private interface.

Load in the ini file specified in filename, and return the settings in a multidimensional array, with the section names and settings included. All section names and keys are lowercased.

Parameters
$filenameThe filename of the ini file to parse
Returns
An associative array containing the data
Author
: Sebastien Cevey seb@c.nosp@m.ine7.nosp@m..net Original Code base: info@.nosp@m.mega.nosp@m.man.n.nosp@m.l Added comment handling/Removed process sections flag: Ingo Herwig

Definition at line 518 of file InifileConfiguration.php.

processValues ( )
protected

Process the values in the ini array.

This method turns string values that hold array definitions (comma separated values enclosed by curly brackets) into array values.

Definition at line 564 of file InifileConfiguration.php.

processValue ( $value)
protected

Process the values in the ini array.

This method turns string values that hold array definitions (comma separated values enclosed by curly brackets) into array values.

Parameters
$valueA reference to the value

Definition at line 574 of file InifileConfiguration.php.

configMerge (   $array1,
  $array2,
  $override 
)
protected

Merge the second array into the first, preserving entries of the first array unless the second array contains the special key '__inherit' set to false or they are re-defined in the second array.

Parameters
$array1First array.
$array2Second array.
$overrideBoolean whether values defined in array1 should be overridden by values defined in array2.
Returns
The merged array.

Definition at line 600 of file InifileConfiguration.php.

getConfigIncludes (   $array)
protected

Search the given value for a 'include' key in a section named 'config' (case-insensivite)

Parameters
$arrayThe array to search in
Returns
Mixed

Definition at line 632 of file InifileConfiguration.php.

serialize ( )
protected

Store the instance in the filesystem.

If the instance is modified, this call is ignored.

Definition at line 649 of file InifileConfiguration.php.

unserialize (   $parsedFiles)
protected

Retrieve parsed ini data from the file system and update the current instance.

If the current instance is modified or any file given in parsedFiles is newer than the serialized data, this call is ignored. If InifileConfiguration class changed, the call will be ignored as well.

Parameters
$parsedFilesAn array of ini filenames that must be contained in the data.
Returns
Boolean whether the data could be retrieved or not

Definition at line 671 of file InifileConfiguration.php.

getSerializeFilename (   $parsedFiles)
protected

Get the filename for the serialized data that correspond to the the given ini file sequence.

Parameters
$parsedFilesAn array of parsed filenames
Returns
Filename

Definition at line 703 of file InifileConfiguration.php.

checkFileDate (   $fileList,
  $referenceFile 
)
protected

Check if one file in fileList is newer than the referenceFile.

Parameters
$fileListAn array of files
$referenceFileThe file to check against
Returns
True, if one of the files is newer, false else

Definition at line 715 of file InifileConfiguration.php.

configChanged ( )
protected

Notify configuration change listeners.

Definition at line 727 of file InifileConfiguration.php.

buildLookupTable ( )
protected

Build the internal lookup table.

Definition at line 743 of file InifileConfiguration.php.

lookup (   $section,
  $key = null 
)
protected

Lookup section and key.

Parameters
$sectionThe section to lookup
$keyThe key to lookup (optional)
Returns
Array with section as first entry and key as second or null if not found

Definition at line 763 of file InifileConfiguration.php.