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, $cachePath=null)
 
 __toString ()
 
 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()

__construct (   $configPath,
  $cachePath = null 
)

Constructor.

Parameters
$configPathThe path, either absolute or relative to the executed script
$cachePathThe cache path, either absolute or relative to the executed script (optional)

Definition at line 56 of file InifileConfiguration.php.

Member Function Documentation

◆ __toString()

__toString ( )

Definition at line 65 of file InifileConfiguration.php.

◆ getConfigPath()

getConfigPath ( )

Get the file system path to the configuration files.

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

Definition at line 83 of file InifileConfiguration.php.

◆ getConfigurations()

getConfigurations ( )

Configuration interface.

See also
Configuration::getConfigurations()

Implements Configuration.

Definition at line 94 of file InifileConfiguration.php.

◆ addConfiguration()

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 103 of file InifileConfiguration.php.

◆ processFile()

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 174 of file InifileConfiguration.php.

◆ getSections()

getSections ( )
See also
Configuration::getSections()

Implements Configuration.

Definition at line 201 of file InifileConfiguration.php.

◆ hasSection()

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

Implements Configuration.

Definition at line 208 of file InifileConfiguration.php.

◆ getSection()

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

Implements Configuration.

Definition at line 215 of file InifileConfiguration.php.

◆ hasValue()

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

Implements Configuration.

Definition at line 235 of file InifileConfiguration.php.

◆ getValue()

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

Implements Configuration.

Definition at line 242 of file InifileConfiguration.php.

◆ getBooleanValue()

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

Implements Configuration.

Definition at line 255 of file InifileConfiguration.php.

◆ getDirectoryValue()

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

Implements Configuration.

Definition at line 263 of file InifileConfiguration.php.

◆ getFileValue()

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

Implements Configuration.

Definition at line 280 of file InifileConfiguration.php.

◆ getKey()

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

Implements Configuration.

Definition at line 297 of file InifileConfiguration.php.

◆ isEditable()

isEditable (   $section)

◆ isModified()

isModified ( )

◆ createSection()

createSection (   $section)

◆ removeSection()

removeSection (   $section)

◆ renameSection()

renameSection (   $oldname,
  $newname 
)

◆ setValue()

setValue (   $key,
  $value,
  $section,
  $createSection = true 
)

◆ removeKey()

removeKey (   $key,
  $section 
)

◆ renameKey()

renameKey (   $oldname,
  $newname,
  $section 
)

◆ writeConfiguration()

writeConfiguration (   $name)

◆ parseIniFile()

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 535 of file InifileConfiguration.php.

◆ processValues()

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 581 of file InifileConfiguration.php.

◆ processValue()

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 591 of file InifileConfiguration.php.

◆ configMerge()

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 617 of file InifileConfiguration.php.

◆ getConfigIncludes()

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 649 of file InifileConfiguration.php.

◆ serialize()

serialize ( )
protected

Store the instance in the file system.

If the instance is modified, this call is ignored.

Definition at line 666 of file InifileConfiguration.php.

◆ unserialize()

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 690 of file InifileConfiguration.php.

◆ getSerializeFilename()

getSerializeFilename (   $parsedFiles)
protected

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

NOTE: The method returns null, if no cache path is configured

Parameters
$parsedFilesAn array of parsed filenames
Returns
String

Definition at line 720 of file InifileConfiguration.php.

◆ checkFileDate()

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 735 of file InifileConfiguration.php.

◆ configChanged()

configChanged ( )
protected

Notify configuration change listeners.

Definition at line 747 of file InifileConfiguration.php.

◆ buildLookupTable()

buildLookupTable ( )
protected

Build the internal lookup table.

Definition at line 763 of file InifileConfiguration.php.

◆ lookup()

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 783 of file InifileConfiguration.php.