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

Class: Config_Container

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

Class Overview


Interface for Config containers


Author(s):

Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 28]
Interface for Config containers


[ Top ]


Class Variables

$attributes =

[line 65]

Array of attributes for this item

Type:   array


[ Top ]

$children =

[line 53]

Container object children

Type:   array


[ Top ]

$content =  ''

[line 47]

Container object content

Type:   string


[ Top ]

$name =  ''

[line 41]

Container object name

Type:   string


[ Top ]

$parent =

[line 59]

Reference to container object's parent

Type:   object


[ Top ]

$type =

[line 35]

Container object type

Ex: section, directive, comment, blank


Type:   string


[ Top ]



Method Detail

Config_Container (Constructor)   [line 85]

Config_Container Config_Container( [string $type = 'section'], [string $name = ''], [string $content = ''], [array $attributes = null])

Constructor

Parameters:

string   $type     Type of container object
string   $name     Name of container object
string   $content     Content of container object
array   $attributes     Array of attributes for container object

[ Top ]

addItem   [line 152]

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

Adds an item to this item.
  • Return: reference to added container on success, Pear_Error on error

Parameters:

object   $item     a container object
string   $where     choose a position 'bottom', 'top', 'after', 'before'
object   $target     needed if you choose 'before' or 'after' in $where

[ Top ]

countChildren   [line 384]

int countChildren( [string $type = null], [string $name = null])

Returns how many children this container has
  • Return: number of children found

Parameters:

string   $type     type of children counted
string   $name     name of children counted

[ Top ]

createBlank   [line 214]

object reference &createBlank( [mixed $where = 'bottom'], [mixed $target = null])

Adds a blank line to this item.

This is a helper method that calls createItem

  • Return: to new item or Pear_Error

[ Top ]

createComment   [line 203]

object reference &createComment( [string $content = ''], [string $where = 'bottom'], [object $target = null])

Adds a comment to this item.

This is a helper method that calls createItem

  • Return: to new item or Pear_Error

Parameters:

string   $content     Object content
string   $where     Position : 'top', 'bottom', 'before', 'after'
object   $target     Needed when $where is 'before' or 'after'

[ Top ]

createDirective   [line 230]

object reference &createDirective( string $name, string $content, [mixed $attributes = null], [string $where = 'bottom'], [object $target = null])

Adds a directive to this item.

This is a helper method that calls createItem

  • Return: to new item or Pear_Error

Parameters:

string   $name     Name of new directive
string   $content     Content of new directive
mixed   $attributes     Directive attributes
string   $where     Position : 'top', 'bottom', 'before', 'after'
object   $target     Needed when $where is 'before' or 'after'

[ Top ]

createItem   [line 105]

object reference &createItem( string $type, mixed $item, string $content, [array $attributes = null], [string $where = 'bottom'], [object $target = null])

Create a child for this item.
  • Return: to new item or Pear_Error

Parameters:

string   $type     type of item: directive, section, comment, blank...
mixed   $item     item name
string   $content     item content
array   $attributes     item attributes
string   $where     choose a position 'bottom', 'top', 'after', 'before'
object   $target     needed if you choose 'before' or 'after' for where

[ Top ]

createSection   [line 248]

object reference &createSection( string $name, [array $attributes = null], [string $where = 'bottom'], [object $target = null])

Adds a section to this item.

This is a helper method that calls createItem If the section already exists, it won't create a new one. It will return reference to existing item.

  • Return: to new item or Pear_Error

Parameters:

string   $name     Name of new section
array   $attributes     Section attributes
string   $where     Position : 'top', 'bottom', 'before', 'after'
object   $target     Needed when $where is 'before' or 'after'

[ Top ]

getAttribute   [line 595]

mixed getAttribute( string $attribute)

Get one attribute value of this item
  • Return: item's attribute value

Parameters:

string   $attribute     Attribute key

[ Top ]

getAttributes   [line 585]

array getAttributes( )

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

[ Top ]

getChild   [line 494]

mixed &getChild( [mixed $index = 0])

Returns the item parent object.
  • Return: returns reference to child object or false if child does not exist

[ Top ]

getContent   [line 534]

string getContent( )

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

[ Top ]

getItem   [line 274]

mixed &getItem( [string $type = null], [mixed $name = null], [mixed $content = null], [array $attributes = null], [int $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', null, 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. For a deeper search, use searchPath()

  • Return: reference to item found or false when not found
  • See: &searchPath()

Parameters:

string   $type     Type of item: directive, section, comment, blank...
mixed   $name     Item name
mixed   $content     Find item with this content
array   $attributes     Find item with attribute set to the given value
int   $index     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 443]

int getItemIndex( )

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

[ Top ]

getItemPosition   [line 462]

int getItemPosition( )

Returns the item rank in its parent children array according to other items with same type and name.
  • Return: returns int or null if root object

[ Top ]

getName   [line 516]

string getName( )

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

[ Top ]

getParent   [line 485]

object returns &getParent( )

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

[ Top ]

getType   [line 552]

string getType( )

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

[ Top ]

isRoot   [line 633]

bool isRoot( )

Is this item root, in a config container object
  • Return: true if item is root

[ Top ]

removeItem   [line 426]

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 ]

searchPath   [line 350]

mixed &searchPath( mixed $args)

Finds a node using XPATH like format:

search format = array ( item,item,item,item) item = 'string' .. will match the <string of the xml element item = array('string',array('name'=>'xyz')) .. will match <string name="xyz">

  • Return: Config_Container object, array of Config_Container objects or false on failure.
  • Access: public

Parameters:

mixed   $args     Search path and attributes

[ Top ]

setAttributes   [line 562]

void setAttributes( array $attributes)

Set this item's attributes.

Parameters:

array   $attributes     Array of attributes

[ Top ]

setContent   [line 525]

void setContent( mixed $content)

Set this item's content.

[ Top ]

setDirective   [line 615]

object newly &setDirective( string $name, mixed $content, [int $index = -1])

Set a children directive content.

This is an helper method calling getItem and addItem or setContent for you. If the directive does not exist, it will be created at the bottom.

  • Return: set directive

Parameters:

string   $name     Name of the directive to look for
mixed   $content     New content
int   $index     Index of the directive to set, in case there are more than one directive with the same name

[ Top ]

setName   [line 507]

void setName( mixed $name)

Set this item's name.

[ Top ]

setType   [line 543]

void setType( mixed $type)

Set this item's type.

[ Top ]

toArray   [line 669]

array toArray( )

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

Format : section[directive][index] = value If the container has attributes, it will use '@' and '#' index is here because multiple directives can have the same name.


[ Top ]

toString   [line 647]

mixed toString( string $configType, [array $options = array()])

Call the toString methods in the container plugin
  • Return: true on success or PEAR_ERROR

Parameters:

string   $configType     Type of configuration used to generate the string
array   $options     Specify special options used by the parser

[ Top ]

updateAttributes   [line 572]

void updateAttributes( array $attributes)

Set this item's attributes.

Parameters:

array   $attributes     Array of attributes

[ Top ]

writeDatasrc   [line 722]

mixed writeDatasrc( mixed $datasrc, string $configType, [array $options = array()])

Writes the configuration to a file
  • Return: true on success or PEAR_ERROR
  • Access: public

Parameters:

mixed   $datasrc     Info on datasource such as path to the configuraton file or dsn...
string   $configType     Type of configuration
array   $options     Options for writer

[ Top ]


Documentation generated on Sat, 1 May 2004 00:32:10 +0200 by phpDocumentor 1.2.3. PEAR Logo Copyright © PHP Group 2004.