eRegistry

Τελευταία ενημέρωση από 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

Έχει διαβαστεί 4149 φορές
Ετικέτες: eregistry libraries efactory
eFactory
Προηγούμενο άρθρο
eFactory
elxisFiles
Επόμενο άρθρο
elxisFiles

Μπορείτε να αντιγράψετε, διανείμετε και παρουσιάσετε τα άρθρα αυτού του ιστότοπου για μη εμπορικούς σκοπούς.
Creative Commons 3.0