Source for file Config.class.php

Documentation is available at Config.class.php

  1. <?php
  2. /**
  3.  * Gumbo Library Framework
  4.  *
  5.  * LICENSE
  6.  * This library is being released under the terms of the New BSD License.  A
  7.  * copy of the license is packaged with the software (LICENSE.txt).  If no
  8.  * copy is found, a copy of the license template can be found at:
  9.  * http://www.opensource.org/licenses/bsd-license.php
  10.  * 
  11.  * @category Gumbo
  12.  * @package Config
  13.  * @copyright Copyright (c) 2007, iBayou, Michael Luster
  14.  * @license http://www.opensource.org/licenses/bsd-license.php New BSD License
  15.  * @author Michael Luster <mluster79@yahoo.com>
  16.  * @link http://sourceforge.net/projects/phpgumbo
  17.  * @version 0.0.1
  18.  */
  19.  
  20. /**
  21.  * Config Interface
  22.  * 
  23.  * This interface will be responsible for defining any operations to be
  24.  * performed on Configuration Files.  A single operation must be defined by
  25.  * a method ('read').  Once the operation is set, a new Config Interface should
  26.  * be written that represents the operation ('Gumbo_Interface_Config_Reader').
  27.  * Any operation class will define the implementation for processing a particular
  28.  * type of configuration file ('ini').  For example, an INI Reader class
  29.  * ('Gumbo_Config_Reader_Ini') will define the implementation for parsing an
  30.  * INI file.  This will be different if a class reads an XML file into memory.
  31.  * 
  32.  * This system makes the package completely extensible to any type of configuration
  33.  * file, whether it be an 'ini', a 'php' file, an 'xml' or any other type of
  34.  * file containing configuration information.  The programmer would simply create
  35.  * different types of Operational Config classes to work on specific file types.
  36.  * 
  37.  * All new Config Operations should define an operation method in the primary
  38.  * Config Interface, and create a new Operation Interface inside the
  39.  * 'gumbo/interface/config/' directory.  The Interface name should follow the
  40.  * rules already defined 'Gumbo_Interface_Config_Operation'.
  41.  * 
  42.  * If we were writing a 'Reader' operation, the following steps should be followed
  43.  * in order to complete extension.  The 'Reader' operation is already defined, so
  44.  * use the current setup as examples during the steps.
  45.  * 
  46.  * 1. Define the operation and what it will do: 'read' will read a file of a
  47.  * given type into memory and returned the data into a Composite object.
  48.  * 
  49.  * 2. Define the Interface to match the operation: 'Gumbo_Interface_Config_Reader'.
  50.  * 
  51.  * 3. Implement the new operation in the Config Class. (see Gumbo_Config::read)
  52.  * 
  53.  * 4. Create 'Reader' classes that parse particular files.  At the time of this
  54.  * writing, the only available Readers are 'Ini' and 'Php'.  To create more, simply
  55.  * create a class that implements the Operation Interface ('Reader').  The type
  56.  * would indicate the type of file being sent.  It is important to remember that
  57.  * the 'type' does not have to be a file type.  For example, a Reader of type Foo
  58.  * will parse an INI file, but perform required processing of certain sections in
  59.  * order to return the proper results.
  60.  * - Gumbo_Config_Reader_Ini // INI File Reader
  61.  * - Gumbo_Config_Reader_Php // PHP Config File Reader
  62.  * - Gumbo_Config_Reader_Xml // XML Config File Reader
  63.  * - Gumbo_Config_Reader_Foo // Foo Config File Reader
  64.  *
  65.  * @category Gumbo
  66.  * @package Config
  67.  * @copyright Copyright (c) 2007, iBayou, Michael Luster
  68.  * @license http://www.opensource.org/licenses/bsd-license.php New BSD License
  69.  * @author Michael Luster <mluster79@yahoo.com>
  70.  * @link http://sourceforge.net/projects/phpgumbo
  71.  * @desc Config Interface
  72.  * @version 0.0.1
  73.  */
  74.  
  75. gumbo_load ("Interface_Composite");
  76.  
  77.     
  78.     /** ACTION METHODS **/
  79.     /**
  80.      * Reads the configuration file and returns the values
  81.      * @param string $file file to load (full path)
  82.      * @param string $type type of configuration file
  83.      * @return Gumbo_Interface_Composite 
  84.      * @see Gumbo_Interface_Composite
  85.      */
  86.     public function read ($file$type="ini");
  87.     
  88.     /**
  89.      * Writes a configuration file
  90.      * @param Gumbo_Interface_Composite $tree data to write
  91.      * @param string $file file name (full path)
  92.      * @param string $type type of configuration file
  93.      * @param bool $replace replaces the current file
  94.      * @return bool if operation was successful
  95.      */
  96.     public function write (Gumbo_Interface_Composite $tree$file$type="ini"$replace=true);
  97.     
  98. }
  99.  
  100. ?>