Source for file Config.class.php
Documentation is available at Config.class.php
* Gumbo Library Framework
* This library is being released under the terms of the New BSD License. A
* copy of the license is packaged with the software (LICENSE.txt). If no
* copy is found, a copy of the license template can be found at:
* http://www.opensource.org/licenses/bsd-license.php
* @copyright Copyright (c) 2007, iBayou, Michael Luster
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
* @author Michael Luster <mluster79@yahoo.com>
* @link http://sourceforge.net/projects/phpgumbo
* This interface will be responsible for defining any operations to be
* performed on Configuration Files. A single operation must be defined by
* a method ('read'). Once the operation is set, a new Config Interface should
* be written that represents the operation ('Gumbo_Interface_Config_Reader').
* Any operation class will define the implementation for processing a particular
* type of configuration file ('ini'). For example, an INI Reader class
* ('Gumbo_Config_Reader_Ini') will define the implementation for parsing an
* INI file. This will be different if a class reads an XML file into memory.
* This system makes the package completely extensible to any type of configuration
* file, whether it be an 'ini', a 'php' file, an 'xml' or any other type of
* file containing configuration information. The programmer would simply create
* different types of Operational Config classes to work on specific file types.
* All new Config Operations should define an operation method in the primary
* Config Interface, and create a new Operation Interface inside the
* 'gumbo/interface/config/' directory. The Interface name should follow the
* rules already defined 'Gumbo_Interface_Config_Operation'.
* If we were writing a 'Reader' operation, the following steps should be followed
* in order to complete extension. The 'Reader' operation is already defined, so
* use the current setup as examples during the steps.
* 1. Define the operation and what it will do: 'read' will read a file of a
* given type into memory and returned the data into a Composite object.
* 2. Define the Interface to match the operation: 'Gumbo_Interface_Config_Reader'.
* 3. Implement the new operation in the Config Class. (see Gumbo_Config::read)
* 4. Create 'Reader' classes that parse particular files. At the time of this
* writing, the only available Readers are 'Ini' and 'Php'. To create more, simply
* create a class that implements the Operation Interface ('Reader'). The type
* would indicate the type of file being sent. It is important to remember that
* the 'type' does not have to be a file type. For example, a Reader of type Foo
* will parse an INI file, but perform required processing of certain sections in
* order to return the proper results.
* - Gumbo_Config_Reader_Ini // INI File Reader
* - Gumbo_Config_Reader_Php // PHP Config File Reader
* - Gumbo_Config_Reader_Xml // XML Config File Reader
* - Gumbo_Config_Reader_Foo // Foo Config File Reader
* @copyright Copyright (c) 2007, iBayou, Michael Luster
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
* @author Michael Luster <mluster79@yahoo.com>
* @link http://sourceforge.net/projects/phpgumbo
gumbo_load ("Interface_Composite");
* Reads the configuration file and returns the values
* @param string $file file to load (full path)
* @param string $type type of configuration file
* @return Gumbo_Interface_Composite
* @see Gumbo_Interface_Composite
public function read ($file, $type=
"ini");
* Writes a configuration file
* @param Gumbo_Interface_Composite $tree data to write
* @param string $file file name (full path)
* @param string $type type of configuration file
* @param bool $replace replaces the current file
* @return bool if operation was successful
public function write (Gumbo_Interface_Composite $tree, $file, $type=
"ini", $replace=
true);