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

Class: Config_Container

Source Location: /Config-1.1/Config/Container.php

Class Overview


Interface for Config containers


Author(s):

Variables

Methods


Child classes:

Config_Container_Apache
Config parser for apache httpd.conf files
Config_Container_GenericConf
Config parser for generic .conf files like htdig.conf...
Config_Container_IniCommented
Config parser for PHP .ini files with comments
Config_Container_IniFile
Config parser for PHP .ini files Faster because it uses parse_ini_file() but get rid of comments.
Config_Container_PHPArray
Config parser for common PHP configuration array such as found in the horde project.

Inherited Variables

Inherited Methods


Class Details

[line 26]
Interface for Config containers


[ Top ]


Class Variables

$children =

[line 50]

Container object children

Type:   array


[ Top ]

$content =  ''

[line 44]

Container object content

Type:   string


[ Top ]

$name =  ''

[line 38]

Container object name

Type:   string


[ Top ]

$options = array()

[line 62]

Contains the options used by the parser

Type:   array


[ Top ]

$parent =

[line 56]

Reference to container object's parent

Type:   object


[ Top ]

$type =

[line 32]

Container object type

Type:   string


[ Top ]



Method Detail

Config_Container (Constructor)   [line 72]

Config_Container Config_Container( [string $type = ''], [string $name = ''], [string $content = ''], object parent &$parent)

Constructor

Parameters:

string   $type     type (optional)Type of container object
string   $name     name (optional)Name of container object
string   $content     content (optional)Content of container object
object parent   &$parent     Reference to parent object, is null for root element.

[ Top ]

addItem   [line 91]

object reference &addItem( [string $type = null], [mixed $item = null], [string $content = ''])

Adds an item to this item.
  • Return: to new item

Parameters:

string   $type     type type of item: directive, section, comment, blank...
mixed   $item     item item name or an item container object
string   $content     content object content

[ Top ]

getContent   [line 314]

mixed getContent( )

Get this item's content.
  • Return: item's value

[ Top ]

getItem   [line 126]

mixed &getItem( string $type, [mixed $name = null], [int $content = null], [mixed $index = -1])

Tries to find the specified item(s) and returns the objects.

Examples: $directives =& $obj->getItem('directive'); $directive_bar_4 =& $obj->getItem('directive', 'bar', '', 4); $section_foo =& $obj->getItem('section', 'foo');

This method can only be called on an object of type 'section'. Note that root is a section. This method is not recursive and tries to keep the current structure.

  • Return: reference to item found or false when not found

Parameters:

string   $type     type type of item: directive, section, comment, blank...
mixed   $name     name (optional)item name
int   $content     index (optional)index of the item in the returned object list. If it is not set, will try to return the last item with this name.

[ Top ]

getItemIndex   [line 256]

int getItemIndex( )

Returns the item position in its parent children array.
  • Return: returns int or null if root object

[ Top ]

getName   [line 296]

string getName( )

Get this item's name.
  • Return: item's type

[ Top ]

getParent   [line 278]

object returns &getParent( )

Returns the item parent object.
  • Return: parent object or null if root object

[ Top ]

getType   [line 332]

string getType( )

Get this item's type.
  • Return: item's type

[ Top ]

insertItem   [line 189]

mixed &insertItem( string $type, mixed $item, [string $content = ''], [string $where = 'bottom'], [object target $target = null])

Inserts an item to a specified position.

The position is relative to a target object if it is defined. Example: $obj->insertItem('section', 'new section', '', 'top'); $obj->insertItem('comment', 'A comment line', 'before', $servertype);

This method can only be called on an object of type 'section'. This method is not recursive and tries to keep the current structure.

  • Return: reference to inserted item or PEAR_Error

Parameters:

string   $type     type type of item: directive, section, comment, blank...
mixed   $item     item item name or item object
string   $content     content (optional)item content
string   $where     where (optional)position: top, bottom, before or after.
object target   $target     (optional)object to insert before or after.

[ Top ]

removeItem   [line 239]

mixed removeItem( )

Deletes an item (section, directive, comment...) from the current object

TODO: recursive remove in sub-sections

  • Return: true if object was removed, false if not, or PEAR_Error if root

[ Top ]

setContent   [line 305]

void setContent( mixed $content)

Set this item's content.

[ Top ]

setName   [line 287]

void setName( mixed $name)

Set this item's name.

[ Top ]

setOptions   [line 393]

void setOptions( array $options)

Imports the requested options if allowed
  • Access: public

Parameters:

array   $options     List of options to set

[ Top ]

setType   [line 323]

void setType( mixed $type)

Set this item's type.

[ Top ]

toArray   [line 354]

array toArray( )

Returns a key/value pair array of the container and its children.

Format : section[directive][index] = value index is here because multiple directives can have the same name.

  • Access: public

[ Top ]

toString   [line 342]

null toString( )

Interface method
  • Access: public

Overridden in child classes as:

Config_Container_Apache::toString()
Returns a formatted string of the object
Config_Container_GenericConf::toString()
Returns a formatted string of the object
Config_Container_IniCommented::toString()
Returns a formatted string of the object
Config_Container_IniFile::toString()
Returns a formatted string of the object
Config_Container_PHPArray::toString()
Returns a formatted string of the object

[ Top ]

writeDatasrc   [line 408]

PEAR_ERROR writeDatasrc( string $datasrc)

Writes the configuration to a file Must be overriden in case you don't use files.
  • Return: or true
  • Access: public

Parameters:

string   $datasrc     datasrc path to the configuraton file

[ Top ]


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