eRegistry

Last update by Elxis Team

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 function set($obj, $idx='')
Stores a new object into the registry. Returns true or false.

get

static public function get($idx)
Gets an object from the registry. Returns object or null on error.

gets

static public function gets($idxs)
Gets multiple object from the registry and returns them as an array.

isLoaded

static public function isLoaded($idx)
Checks if an object is registered. Returns true or false.

remove

static public function remove($idx)
Destroys an object and removes it from the registry.

getAll

static public function getAll()
Returns an array consisted by the index names of all registered objects in the registry.

Examples

$object = new mySuperClass();
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

It has been read 4138 times
eFactory
Previous article
eFactory
elxisFiles
Next article
elxisFiles

You are free to copy, distribute and transmit the articles in this site for non-commercial purposes.
Creative Commons 3.0