eRegistry is a repository of initiated object instances.
eRegistry is a repository of initiated object instances. These instances are stored into the static property $registry.
Usually eRegistry is accessed internally by Elxis so a developer doesn't have to work directly with it. Elxis has eFactory for this purpose. eFactory mostly acts like a shortcut interface to eRegistry but also initiates the object if it is not yet initiated.
$eDate = eRegistry::get('eDate');
Get the instance of elxisDate class from the registry.
$eDate = eFactory::getDate();
Get/Initiate the instance of elxisDate class by using eFactory (recommended).
Methods
The following methods are available in the eRegistry class.
set
static public functionset($obj, $idx='')
Stores a new object into the registry. Returns true or false.
get
static public functionget($idx)
Gets an object from the registry. Returns object or null on error.
gets
static public functiongets($idxs)
Gets multiple object from the registry and returns them as an array.
isLoaded
static public functionisLoaded($idx)
Checks if an object is registered. Returns true or false.
remove
static public functionremove($idx)
Destroys an object and removes it from the registry.
getAll
static public functiongetAll()
Returns an array consisted by the index names of all registered objects in the registry.
Examples
$object = newmySuperClass();
eRegistry::set($object, 'myIndex');
Save an instance of class mySuperClass into the registry
$object = eRegistry::get('myIndex');
Get the saved instance of class mySuperClass from the registry