Gumbo_Interface_Config



Config Interface

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

Author(s): Michael Luster <mluster79@yahoo.com>
License:New BSD License
Copyright:Copyright (c) 2007, iBayou, Michael Luster
Link:http://sourceforge.net/projects/phpgumbo
Version:0.0.1

Interface Methods

public Gumbo_Interface_Composite read ( string $file, [string $type] ) [line 87]

Reads the configuration file and returns the values

Parameter(s):

  • (string) $file :: file to load (full path)
  • (string) $type :: type of configuration file

[ Top ]
public bool write ( $tree, string $file, [string $type], [bool $replace] ) [line 97]

Writes a configuration file

Parameter(s):

  • (Gumbo_Interface_Composite) $tree :: data to write
  • (string) $file :: file name (full path)
  • (string) $type :: type of configuration file
  • (bool) $replace :: replaces the current file
  • return:  if operation was successful

[ Top ]