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

Class: Config_Container

Source Location: /Config-1.2/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 75]

Config_Container &Config_Container( [string $type = ''], [string $name = ''], [string $content = ''], [mixed $attributes = null])

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
mixed   $attributes     attributes (optional)Array of attributes for container object

[ Top ]

addItem   [line 142]

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

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

Parameters:

object item   &$item     a container object
string   $where     where (optional)choose a position 'bottom', 'top', 'after', 'before'
object target   $target     (optional)needed if you choose 'before' or 'after' for where

[ Top ]

countChildren   [line 307]

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

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

Parameters:

string   $type     type (optional)type of children counted
string   $name     type (optional)name of children counted

[ Top ]

createBlank   [line 203]

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 191]

object reference &createComment( [string $content = ''], [mixed $where = 'bottom'], [mixed $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     content object content

[ Top ]

createDirective   [line 218]

object reference &createDirective( string $name, string $content, [mixed $attributes = null], [mixed $where = 'bottom'], [mixed $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 Name of new directive
string   $content     content Content of new directive
mixed   $attributes     attributes (optional)Directive attributes

[ Top ]

createItem   [line 95]

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

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

Parameters:

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

[ Top ]

createSection   [line 234]

object reference &createSection( string $name, [mixed $attributes = null], [mixed $where = 'bottom'], [mixed $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 Name of new section
mixed   $attributes     attributes (optional)Section attributes

[ Top ]

getAttributes   [line 503]

array getAttributes( )

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

[ Top ]

getChild   [line 426]

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 466]

string getContent( )

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

[ Top ]

getItem   [line 259]

mixed &getItem( string $type, [mixed $name = null], [mixed $content = 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.

  • 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
mixed   $content     content (optional)find item with this content
int   $index     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 366]

int getItemIndex( )

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

[ Top ]

getItemPosition   [line 391]

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 448]

string getName( )

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

[ Top ]

getParent   [line 417]

object returns &getParent( )

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

[ Top ]

getType   [line 484]

string getType( )

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

[ Top ]

isRoot   [line 539]

bool isRoot( )

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

[ Top ]

removeItem   [line 349]

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 ]

setAttributes   [line 494]

void setAttributes( array $attributes)

Set this item's attributes.

Parameters:

array   $attributes     attributes Array of attributes

[ Top ]

setContent   [line 457]

void setContent( mixed $content)

Set this item's content.

[ Top ]

setDirective   [line 521]

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

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:

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

[ Top ]

setName   [line 439]

void setName( mixed $name)

Set this item's name.

[ Top ]

setType   [line 475]

void setType( mixed $type)

Set this item's type.

[ Top ]

toArray   [line 575]

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.

  • Access: public

[ Top ]

toString   [line 554]

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

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

Parameters:

string   $configType     configType Type of configuration used to generate the string
array   $options     options (optional)specify special options used by the parser

[ Top ]

writeDatasrc   [line 623]

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

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

Parameters:

mixed   $datasrc     datasrc info on datasource such as path to the configuraton file or dsn...
string   $configType     configType type of configuration
array   $options     options (optional) Options for writer

[ Top ]


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