API/Di

From aMember Pro Documentation
Revision as of 07:18, 17 November 2011 by Alex-scott (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Am_Di class in aMember implements dependency injection pattern. Instead of using 'singletons in each class, we are using Am_Di instance that stores references to necessary objects, and creates objects by demand.

From controllers (Am_Controller), tables (Am_Table), records (Am_Record) and plugins (Am_Plugin), module bootstraps (Bootstrap_xx), Am_Di instance is accessible with method call $this->getDi();

From other parts of program, including site-custom file 'application/configs/site.php, the same Am_Di instance is available as Am_Di::getInstance().