Config
[ class tree: Config ] [ index: Config ] [ all elements ]

Class: Config

Source Location: /Config-0.3.1/Config.php

Class Overview


Partly implementation of the Config-Interface-API


Author(s):

Version:

  • $Id: Config.php,v 1.4 2002/06/25 14:40:04 chregu Exp $

Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 43]
Partly implementation of the Config-Interface-API

This class implements a part of the API for working on configuration data ConfigDefault implements getValues(), getBlocks(), getValue(), setValue() The data is internally saved in a nested array.

Example: include("Config.php"); $i = new Config("IniFile"); $i -> parseInput( "yourfile.ini"); $ret = $i->getValues('/section');



[ Top ]


Class Variables

$data = array()

[line 55]

contains the internal data structure

Type:   array


[ Top ]

$datasrc =

[line 49]

contains the data source given by parseInput

Type:   string


[ Top ]



Method Detail

Config (Constructor)   [line 67]

Config Config( string $storage_driver, [string $storage_options = ""])

Constructor

requires the type of the data container, if the container needs special parameters during creation, set them with $storage_options

  • Access: public

Parameters:

string   $storage_driver     type of container
string   $storage_options     parameter for container constructor

[ Top ]

array_merge_clobber   [line 316]

array array_merge_clobber( array $a1, array $a2)

There seemed to be no built in function that would merge two arrays recursively and clobber any existing key/value pairs. Array_Merge() is not recursive, and array_merge_recursive seemed to give unsatisfactory results... it would append duplicate key/values.

So here's a cross between array_merge and array_merge_recursive

  • Return: merged array

Parameters:

array   $a1     first array to be merged
array   $a2     second array to be merged

[ Top ]

getBlocks   [line 134]

array getBlocks( [string $block = "/"])

returns all blocks of the given block

If the block not exists, a PEAR_Error will returned, else a array containing all child blocks

  • Return: returns a array containing all values, or a PEAR_Error, if fails
  • Access: public

Parameters:

string   $block     block path

[ Top ]

getValue   [line 209]

mixed getValue( [string $block = "/"], string $key, [string $default = ""])

return the value of the key of the given block

If the block or the key not exists, both will be created and sets on the default. The value or if not exists the default will be returned.

  • Return: type depends of the value
  • Access: public

Parameters:

string   $block     block path
string   $key     key to set
string   $default     default value for the key

[ Top ]

getValues   [line 90]

array getValues( [string $block = "/"])

returns all key-value-pairs of the given block

If the block not exists, a PEAR_Error will returned, else a hash: $array["key"] = value

  • Return: returns a hash containing all values, but a PEAR_Error if fails
  • Access: public

Parameters:

string   $block     block path

[ Top ]

parseInput   [line 241]

mixed parseInput( string $files, [array $feature = Null])

parses the input of the given data source

The format and required content of $datasrc depends of the implementation. If the implemention requires additional data, for example a comment char, it have to deliver in a hash as second argument.

  • Return: returns a PEAR_ERROR, if error occurs
  • Access: public

Parameters:

string   $files     Name of the datasource to parse
array   $feature     Contains a hash of features depending on the implentation

[ Top ]

setValue   [line 175]

mixed setValue( [string $block = "/"], string $key, [string $value = ""])

sets the value of the key of the given block

If the block or the key not exists, both will be created. The value will be returned.


Parameters:

string   $block     block path
string   $key     key to set
string   $value     value for the key

[ Top ]

writeInput   [line 292]

mixed writeInput( [string $datasrc = ""], [boolean $preserve = True])

writes the data to the given data source or if not given to the datasource of parseInput If $datasrc was a array, the last file will used.

See parseInput for $datasrc. If the second argument $preserve is true, the implementation should try to preserve the original format and data of the source except changed or added values. This mean to preserve for example comments in files or so.


Parameters:

string   $datasrc     Name of the datasource to parse
boolean   $preserve     preserving behavior

[ Top ]


Documentation generated on Fri, 30 Apr 2004 21:21:34 +0200 by phpDocumentor 1.2.3. PEAR Logo Copyright © PHP Group 2004.