TIP_Type

Introduction

TIP type system

Source file
/Type.php
abstract
yes

Manages all the instantiable TIP objects (types). Inheriting a class from TIP_Type gives the ability to instantiate this class only when requested (usually throught a call to getInstance()). Multiple requests to getInstance() will references the same - unique - instantiated object.

Also, the PHP file declaring the new type will be included only when required, enabling a real modular environement.

Properties

id : string

Instance identifier

access
protected

type : array

An array of parent classes (without TIP_PREFIX)

access
protected

Methods

checkOptions (&$options) : bool

Check the options

&$options
array
Property values
lines
63 - 71
static
yes
access
protected

Overridable static method that checks $options for missing or invalid values and eventually corrects its content.

__construct ($options)

Constructor

$options
array
Properties values
lines
83 - 89
access
protected

Initializes a TIP_Type instance.

Basically, this class set the properties values by parsing the $options array.

postConstructor ()

Overridable post construction method

lines
99 - 101
access
protected

Called after the construction happened. This can be overriden to do some other post costruction operation.

The TIP_Type::postConstructor() method does nothing.

singleton ([$options], [$dont_store]) : &array|object|null

Singleton method

$options
array|string|null [ = null ]
Constructor options
$dont_store
bool [ = false ]
Don't store the instance in the register
lines
141 - 221
static
yes
access
protected

Manages the singletons. Given a hierarchy of parent types and a string identifier, this method returns a singleton of the instantiated object. If the object is not found, it is dinamically defined and instantiated.

The singletons are stored in a static tree, called register, containing all the hierarchy of the instantiated types.

If $options is not specified, the whole register is returned.

If $options is a string, it must specify a valid type: a partial register content of this type is returned.

In the other cases, $options must be an array of options, and a singleton for the specified object is returned. In this situation, $options must have at least the following items: * $options['id']: the instance identifier

These types must be lowercase strings specifying the parent classes of the instance (TIP_Type excluded) without TIP_PREFIX. Using array('module', 'content'),

for instance, will instantiate a TIP_Content object.

Some type automatically fills $options['id'] after the checkOptions() call: check the documentation for each class for further information.

getInstance ($id, [$required]) : &TIP_Type

Type instantiation

$id
mixed
Instance identifier
$required
bool [ = true ]
true if errors must be fatals
lines
237 - 269
static
yes
access
public

Gets the singleton of a configured object. $id could be any identifier defined in $GLOBALS['cfg'].

An internal register is mantained to avoid singleton() calls with the same $id.

__toString () : string

Return the id of a TIP instance

lines
275 - 278
access
public

getType () : string

Get the type of a TIP instance

lines
292 - 295
access
public

Returns the type of the current - instantiated - TIP object. This function simply gets the class name (in lowercase) and strips the TIP_PREFIX from the string.

The result is converted to lowecase to avoid discrepancies between different PHP versions.

getProperty ($property) : &mixed|null

Get a property of this instance

$property
string
The property name
lines
303 - 306
access
public

getOption ($option) : mixed|null

Get a global option for the current instance

$option
string
The option to retrieve
lines
317 - 320
access
public

Wrappers the more general TIP::getOption() function without the need to specify the type.

TIP_Type was last modified by TiP on Mon 25 May 2009 06:22:25 PM CEST
Hosted by BerliOS Developer Logo