Base collection, from which other collection classes derive.

This class provides the most basic collection, containing base objects. It has functionality to : - add objects - remove objects - set name of an object (rename) - get the names of all objects in the collection - get an object from the collection - get all objects in the collection - return number of objects in collection

category Core
package Formaid
author Dieter Adriaenssens
copyright 2006-2013 Dieter Adriaenssens
license GPL
link http://formaid.sourceforge.net/
todo collections don't have a name, so when they are added as an object to another collection, they don't have an index by name in the array, which makes it impossible to use the index to track an object. Solution : don't depend on index (key), refactor all code to remove this, remove all functions that use the index by name, OR, give collections a name (implementing a ObjectInterface with getName() and setName() public methods)

 Methods

Constructor, initialises an instance of base object collection

__construct() : void

Adds a new instance to the collection

add(object $obj) : void

If the object is of the Formaid_Object class, add it to the collection. If the object is not a class, create a new base object instance.

Parameters

$obj

object

Formaid_Object instance or name of new Formaid_Object

Displays all objects in the collection

display() : void

Get display seperator

getDisplayListSeparator() : string

Returns

stringString separating columns

Get display prefix

getDisplayPrefix() : string

Returns

stringPrefix string when displaying collection items

Generate formatted string of all objects

getDisplayString() : string

A displaystring is generated from all objects in the collection, all empty strings are removed and the remaining ones are chained together with the listSeparator.

Returns

string

Get display suffix

getDisplaySuffix() : string

Returns

stringSuffix string when displaying collection items

Returns name of the object

getName(string $name) : string

Parameters

$name

string

object name

Returns

stringobject name

Returns names of all objects in collection

getNames() : array

Returns

arrayobject names

Returns object

getObject(string $name) : object

Parameters

$name

string

object name

Returns

object

Returns all objects in collection

getObjects() : array

Returns

arrayobjects

Checks if name of the selected object is empty

isNameEmpty(string $name) : bool

Parameters

$name

string

object name

Returns

booltrue if empty

Returns number of objects in collection

numItems() : int

Returns

intnumber of objects in collection

Removes the object from the collection

remove(string $name) : void

Parameters

$name

string

object name

Set display pre- and suffix

setDisplayAffixes(string $prefix, string $suffix) : void

Parameters

$prefix

string

prefix string when displaying collection items

$suffix

string

suffix string when displaying collection items

Set display seperator for list mode

setDisplayListSeparator(string $separator) : void

Parameters

$separator

string

string separating columns

Set display prefix

setDisplayPrefix(string $prefix) : void

Parameters

$prefix

string

prefix string when displaying collection items

Set display suffix

setDisplaySuffix(string $suffix) : void

Parameters

$suffix

string

suffix string when displaying collection items

Sets new name for the object

setName(string $name, string $new_name) : void

Parameters

$name

string

object name

$new_name

string

new name

Show all objects in collection

show() : void

The show method of every object is called. These functions print the object (name, value, ...) to stdout.

deprecated use display()

Add pre- and suffixes to display string

addDisplayAffixes(string $displayString) : string

The pre- and suffix should only be displayed when at least one item is displayed.

Parameters

$displayString

string

String with collection items to be displayed

Returns

stringString with added affixes

Callback method used by getDisplayString()

callbackDisplayString(object $object) : string
Static

It calls the getDisplayString() method of the instance

static

Parameters

$object

object

Instance to apply the method to

Returns

stringDisplaystring of object

 Properties

 

$collection : array
access protected
 

$_displayListSeparator : string
access private
 

$_displayPrefix : string
access private
 

$_displaySuffix : string
access private