Class: I2CE MagicData: Difference between revisions
No edit summary |
No edit summary |
||
Line 33: | Line 33: | ||
Construct a new configuration value or grouping. | Construct a new configuration value or grouping. | ||
*Signature: protected function __construct($name,$parent,$check_key) | *Signature: protected function __construct($name,$parent,$check_key) | ||
Parameters: | *Parameters: | ||
* [http://www.php.net/manual/en/language.types.string.php string ] $name<br/>The name of this configuration setting. | ** [http://www.php.net/manual/en/language.types.string.php string ] $name <br/>The name of this configuration setting. | ||
**Default Value: null | ***Default Value: null | ||
* [[Class: I2CE_MagicDataNode | I2CE_MagicDataNode]] $parent<br/>The parent of this configuration setting. | ** [[Class: I2CE_MagicDataNode | I2CE_MagicDataNode]] $parent <br/>The parent of this configuration setting. | ||
**Default Value: null | ***Default Value: null | ||
* [http://www.php.net/manual/en/language.types.boolean.php boolean ] $check_key<br/>Defaults to true in which case we check that the key is valid. | ** [http://www.php.net/manual/en/language.types.boolean.php boolean ] $check_key <br/>Defaults to true in which case we check that the key is valid. | ||
**Default Value: true | ***Default Value: true | ||
===addStorage()=== | ===addStorage()=== | ||
Add the given storage object to this instance. | Add the given storage object to this instance. The last one added is considered to be the "definitive" one -- the one whose contents should be considered correct. The first one added should be the one which has quickest access | ||
The last one added is considered to be the "definitive" one -- the one whose contents | |||
should be considered correct. The first one added should be the one which has quickest | |||
access | |||
*Signature: public function addStorage($storage) | *Signature: public function addStorage($storage) | ||
Parameters: | *Parameters: | ||
* [[Class: I2CE_MagicDataStorage | I2CE_MagicDataStorage]] $storage | ** [[Class: I2CE_MagicDataStorage | I2CE_MagicDataStorage]] $storage | ||
===clearCache()=== | ===clearCache()=== | ||
Clear caching for each of the storage mechanisms | Clear caching for each of the storage mechanisms @param I2CE_MagicDataNode $node. The node we wish to remove from the cache. If null ( default) we call the clear() method for all but the last added storage mecahnism. If non-null, we call the destory() method for the node on all but the last storage mechanism. | ||
@param I2CE_MagicDataNode $node. The node we wish to remove from the cache. If null ( default) we call the clear() method | |||
for all but the last added storage mecahnism. If non-null, we call the destory() method for the node on all but the last | |||
storage mechanism. | |||
*Signature: public function clearCache() | *Signature: public function clearCache() | ||
*Returns: [http://www.php.net/manual/en/language.types.boolean.php boolean ] | *Returns: [http://www.php.net/manual/en/language.types.boolean.php boolean ] | ||
Line 58: | Line 52: | ||
Destroy the specified node from each of the storage mechanisms | Destroy the specified node from each of the storage mechanisms | ||
*Signature: public function destroy($node) | *Signature: public function destroy($node) | ||
* | *Parameters: | ||
Parameters: | |||
*$node | *$node | ||
*Returns: [http://www.php.net/manual/en/language.types.boolean.php boolean ]<br/>true on success | |||
===getPath()=== | ===getPath()=== | ||
Return the full path to this configuration setting. | Return the full path to this configuration setting. | ||
*Signature: public function getPath($show_top) | *Signature: public function getPath($show_top) | ||
*Parameters: | |||
** [http://www.php.net/manual/en/language.types.boolean.php boolean ] $show_top <br/>defaults to true if we are to show the parent | |||
***Default Value: true | |||
*Returns: [http://www.php.net/manual/en/language.types.string.php string ] | *Returns: [http://www.php.net/manual/en/language.types.string.php string ] | ||
===getPermanentStorageClass()=== | ===getPermanentStorageClass()=== | ||
Gets the class of the permanent storage object (the last one added) | Gets the class of the permanent storage object (the last one added) | ||
Line 73: | Line 67: | ||
*Returns: [http://www.php.net/manual/en/language.types.string.php string ] | *Returns: [http://www.php.net/manual/en/language.types.string.php string ] | ||
===instance()=== | ===instance()=== | ||
Return an instance of this class based on the index given. | Return an instance of this class based on the index given. This will create the instance if it doesn't exist. | ||
This will create the instance if it doesn't exist | |||
*Signature: static public function instance($index,$replace) | *Signature: static public function instance($index,$replace) | ||
*Parameters: | |||
** [http://www.php.net/manual/en/language.types.string.php string ] $index | |||
***Default Value: NULL | |||
** [http://www.php.net/manual/en/language.types.boolean.php boolean ] $replace <br/>Defaults to false. If true and $index is non null, then we create a new instance at $index. | |||
***Default Value: FALSE | |||
*Returns: [[Class: I2CE_MagicData | I2CE_MagicData]] | *Returns: [[Class: I2CE_MagicData | I2CE_MagicData]] | ||
===pathDivider()=== | ===pathDivider()=== | ||
Return the path divider for this MagicDataNode object | Return the path divider for this MagicDataNode object | ||
Line 89: | Line 80: | ||
*Returns: [http://www.php.net/manual/en/language.types.string.php string ] | *Returns: [http://www.php.net/manual/en/language.types.string.php string ] | ||
===retrieve()=== | ===retrieve()=== | ||
Retrieve the given magic data node (which should be a | Retrieve the given magic data node (which should be a descendent of this instance.) | ||
descendent of this instance.) | |||
*Signature: public function retrieve($node) | *Signature: public function retrieve($node) | ||
*Parameters: | |||
** [[Class: I2CE_MagicDataNode | I2CE_MagicDataNode]] $node | |||
*Returns: [http://www.php.net/manual/en/language.types.array.php array ] | *Returns: [http://www.php.net/manual/en/language.types.array.php array ] | ||
===setLocales()=== | ===setLocales()=== | ||
*Signature: public function setLocales($locales) | *Signature: public function setLocales($locales) | ||
Parameters: | *Parameters: | ||
*$locales | *$locales | ||
===store()=== | ===store()=== | ||
Store the given magic data node (which should be a descendent | Store the given magic data node (which should be a descendent of this instance.) Starts storing at the last added storage mechanism until it reaches the first storage mechanism. If it fails saving at any storage mechanis, it will call the destroy method on that storage mechanism and any remaining one. | ||
of this instance.) Starts storing at the last added storage | |||
mechanism until it reaches the first storage mechanism. If it | |||
fails saving at any storage mechanis, it will call the destroy | |||
method on that storage mechanism and any remaining one. | |||
*Signature: public function store($node,$max) | *Signature: public function store($node,$max) | ||
* | *Parameters: | ||
Parameters: | ** [[Class: I2CE_MagicDataNode | I2CE_MagicDataNode]] $node | ||
* [[Class: I2CE_MagicDataNode | I2CE_MagicDataNode]] $node | ** integer $max <br/>The max index of storage objects to save. Defaults to -1 meaning we store on all mechanisms | ||
* integer $max<br/>The max index of storage objects to save. | ***Default Value: -1 | ||
**Default Value: -1 | *Returns: [http://www.php.net/manual/en/language.types.boolean.php boolean ]<br/>true on success. | ||
===tearDown()=== | ===tearDown()=== | ||
Clean up all MagicData instances. Normally, this should not be | Clean up all MagicData instances. Normally, this should not be used. Primarily for unit testing. | ||
used. Primarily for unit testing. | |||
*Signature: static public function tearDown() | *Signature: static public function tearDown() | ||
==Inherited Variables== | ==Inherited Variables== |
Revision as of 23:40, 16 October 2009
This article desrcibes the class I2CE_MagicData.
- Extends the class: I2CE_MagicDataNode.
- Location: Part of the module I2CE in the package I2CE
- Source: Defined in the file lib/I2CE_MagicData.php
Configuration class to lookup and save configuration options.
Variables
$instances
A list of named instances of this class.
- Type: static protected y $instances
$last_instance
The index of the last accessed stored instance of this class
- Type: static protected ng $last_instance
$instance
The instance index for this configuration grouping.
- Type: protected ng $instance
$storage
A list of storage objects to use to store and retrieve values. Values will be saved using all storage objects and retrieved until a match is found in the order the objects are assigned.
- Type: protected y $storage
$num_storage
- Type: protected $num_storage
$locales
- Type: protected $locales
Methods
__construct()
Construct a new configuration value or grouping.
- Signature: protected function __construct($name,$parent,$check_key)
- Parameters:
- string $name
The name of this configuration setting.- Default Value: null
- I2CE_MagicDataNode $parent
The parent of this configuration setting.- Default Value: null
- boolean $check_key
Defaults to true in which case we check that the key is valid.- Default Value: true
- string $name
addStorage()
Add the given storage object to this instance. The last one added is considered to be the "definitive" one -- the one whose contents should be considered correct. The first one added should be the one which has quickest access
- Signature: public function addStorage($storage)
- Parameters:
- I2CE_MagicDataStorage $storage
clearCache()
Clear caching for each of the storage mechanisms @param I2CE_MagicDataNode $node. The node we wish to remove from the cache. If null ( default) we call the clear() method for all but the last added storage mecahnism. If non-null, we call the destory() method for the node on all but the last storage mechanism.
- Signature: public function clearCache()
- Returns: boolean
destroy()
Destroy the specified node from each of the storage mechanisms
- Signature: public function destroy($node)
- Parameters:
- $node
- Returns: boolean
true on success
getPath()
Return the full path to this configuration setting.
- Signature: public function getPath($show_top)
- Parameters:
- boolean $show_top
defaults to true if we are to show the parent- Default Value: true
- boolean $show_top
- Returns: string
getPermanentStorageClass()
Gets the class of the permanent storage object (the last one added)
- Signature: public function getPermanentStorageClass()
- Returns: string
instance()
Return an instance of this class based on the index given. This will create the instance if it doesn't exist.
- Signature: static public function instance($index,$replace)
- Parameters:
- Returns: I2CE_MagicData
pathDivider()
Return the path divider for this MagicDataNode object
- Signature: protected function pathDivider()
- Returns: string
retrieve()
Retrieve the given magic data node (which should be a descendent of this instance.)
- Signature: public function retrieve($node)
- Parameters:
- I2CE_MagicDataNode $node
- Returns: array
setLocales()
- Signature: public function setLocales($locales)
- Parameters:
- $locales
store()
Store the given magic data node (which should be a descendent of this instance.) Starts storing at the last added storage mechanism until it reaches the first storage mechanism. If it fails saving at any storage mechanis, it will call the destroy method on that storage mechanism and any remaining one.
- Signature: public function store($node,$max)
- Parameters:
- I2CE_MagicDataNode $node
- integer $max
The max index of storage objects to save. Defaults to -1 meaning we store on all mechanisms- Default Value: -1
- Returns: boolean
true on success.
tearDown()
Clean up all MagicData instances. Normally, this should not be used. Primarily for unit testing.
- Signature: static public function tearDown()
Inherited Variables
$type
Theis protected variable is inherited from I2CE_MagicDataNode->$type
$name
Theis protected variable is inherited from I2CE_MagicDataNode->$name
$value
Theis protected variable is inherited from I2CE_MagicDataNode->$value
$children
Theis protected variable is inherited from I2CE_MagicDataNode->$children
$parent
Theis protected variable is inherited from I2CE_MagicDataNode->$parent
$parentPath
Theis protected variable is inherited from I2CE_MagicDataNode->$parentPath
$parentPathTop
Theis protected variable is inherited from I2CE_MagicDataNode->$parentPathTop
$top
Theis protected variable is inherited from I2CE_MagicDataNode->$top
$volatile
Theis protected variable is inherited from I2CE_MagicDataNode->$volatile
$attributes
Theis protected variable is inherited from I2CE_MagicDataNode->$attributes