ClassRegistry Class Info:
- Class Declaration:
class ClassRegistry
- File name:
- cake/libs/class_registry.php
- Description:
Class Collections.
A repository for class objects, each registered with a key. If you try to add an object with the same key twice, nothing will come of it. If you need a second instance of an object, give it another key.
- Package
- cake
- Subpackage
- cake.cake.libs
Properties:
addObject
topAdd $object to the registry, associating it with the name $key.
- Parameters:
-
-
string $key required
Key for the object in registry
-
mixed $object required
Object to store
-
- Method defined in:
- cake/libs/class_registry.php on line 183
- Return
boolean True if the object was written, false if $key already exists
- Access
public
- Static
config
topSets the default constructor parameter for an object type
- Parameters:
-
-
string $type required
Type of object. If this parameter is omitted, defaults to "Model"
-
array $param optional array ( )
The parameter that will be passed to object constructors when objects of $type are created
-
- Method defined in:
- cake/libs/class_registry.php on line 274
- Return
mixed Void if $param is being set. Otherwise, if only $type is passed, returns the previously-set value of $param, or null if not set.
- Access
public
- Static
flush
topFlushes all objects from the ClassRegistry.
- Method defined in:
- cake/libs/class_registry.php on line 359
- Return
void
- Access
public
- Static
getInstance
topReturn a singleton instance of the ClassRegistry.
- Method defined in:
- cake/libs/class_registry.php on line 65
- Return
ClassRegistry instance
- Access
public
getObject
topReturn object which corresponds to given key.
- Parameters:
-
-
string $key required
Key of object to look for
-
- Method defined in:
- cake/libs/class_registry.php on line 248
- Return
mixed Object stored in registry or boolean false if the object does not exist.
- Access
public
- Static
init
topLoads a class, registers the object in the registry and returns instance of the object.
Examples
Simple Use: Get a Post model instance ClassRegistry::init('Post');
Exapanded: array('class' => 'ClassName', 'alias' => 'AliasNameStoredInTheRegistry', 'type' => 'TypeOfClass');
Model Classes can accept optional array('id' => $id, 'table' => $table, 'ds' => $ds, 'alias' => $alias);
When $class is a numeric keyed array, multiple class instances will be stored in the registry, no instance of the object will be returned
array(
array('class' => 'ClassName', 'alias' => 'AliasNameStoredInTheRegistry', 'type' => 'TypeOfClass'),
array('class' => 'ClassName', 'alias' => 'AliasNameStoredInTheRegistry', 'type' => 'TypeOfClass'),
array('class' => 'ClassName', 'alias' => 'AliasNameStoredInTheRegistry', 'type' => 'TypeOfClass')
);
- Parameters:
-
-
mixed $class required
as a string or a single key => value array instance will be created, stored in the registry and returned.
-
string $type optional NULL
TypeOfClass
-
- Method defined in:
- cake/libs/class_registry.php on line 99
- Return
object instance of ClassName
- Access
public
- Static
isKeySet
topReturns true if given key is present in the ClassRegistry.
- Parameters:
-
-
string $key required
Key to look for
-
- Method defined in:
- cake/libs/class_registry.php on line 217
- Return
boolean true if key exists in registry, false otherwise
- Access
public
- Static
keys
topGet all keys from the registry.
- Method defined in:
- cake/libs/class_registry.php on line 235
- Return
array Set of keys stored in registry
- Access
public
- Static
map
topAdd a key name pair to the registry to map name to class in the registry.
- Parameters:
-
-
string $key required
Key to include in map
-
string $name required
Key that is being mapped
-
- Method defined in:
- cake/libs/class_registry.php on line 317
- Access
public
- Static
mapKeys
topGet all keys from the map in the registry.
- Method defined in:
- cake/libs/class_registry.php on line 333
- Return
array Keys of registry's map
- Access
public
- Static
removeObject
topRemove object which corresponds to given key.
- Parameters:
-
-
string $key required
Key of object to remove from registry
-
- Method defined in:
- cake/libs/class_registry.php on line 201
- Return
void
- Access
public
- Static