eFactory

by Elxis Team

Initiate and get library classes.

eFactory serves 3 major tasks:
• Initiates (constructs) not-initiated classes, stores them into the registry and returns an object.
• Returns a class object from the registry for already initiated classes.
• Removes the need of using the global keyword.

Usage

Most common methods of eFactory.

$elxis = eFactory::getElxis();
Initiate/get elxisFramework class

$db = eFactory::getDB();
Initiate/get elxisDatabase class

$eURI = eFactory::getURI();
Initiate/get elxisURI class

$eLang = eFactory::getLang();
Initiate/get elxisLanguage class

$eDoc = eFactory::getDocument();
Initiate/get elxisDocument class

$eDate = eFactory::getDate();
Initiate/get elxisDate class

$eFiles = eFactory::getFiles();
Initiate/get elxisFiles class

$ePathway = eFactory::getPathway();
Initiate/get elxisPathway class

Replacement for global

To call an object ($elxis for example) inside a function that initiated outside of it you would do:

function test() {
global $elxis;
echo $elxis->getConfig('SITENAME');
}

With eFactory you do it like that:

function test() {
$elxis = eFactory::getElxis();
echo $elxis->getConfig('SITENAME');
}

Or, alternatively, by using the chaining methods style (dont do it for repeated object as it will be slower):

function test() {
echo eFactory::getElxis()->getConfig('SITENAME');
}

eFactory also makes sure that you will always get the same instance of the class (as it calls internally the Elxis Registry).

It has been read 6302 times
elxisDate
Previous article
elxisDate
eRegistry
Next article
eRegistry

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