• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Extended Loader - with Bonus Features!


- Load models and libraries from another CI application on the same server
- Autoload models and libraries with aliases from the autoload config file.


- Summary: Basically APPPATH can be overridden by a 4th method parameter $apppath
- Line 5: private $apppath variable
- Line 11: set initial value of $apppath to APPPATH
- Line 14: add 4th paramater to model() method for $apppath
- Lines 18-21: set array key $alias for auto-loading model aliasing support
- Lines 62-65: override $this->apppath for all future model requests
- Line 68: APPPATH was replaced with $this->apppath
- Line 86: APPPATH was replaced with $this->apppath
- Line 97: add 4th paramater to library() method for $apppath
- Lines 109-111: override $this->apppath for all future library requests
- Line 158: APPPATH was replaced with $this->apppath
- Line 202: APPPATH was replaced with $this->apppath
- Lines 380-383: set array key $alias for auto-loading library aliasing support


The only tricky part is that models and libraries loaded from other applications must be loaded last in the application. (i.e. do not load any other models after loading a remote one, or set the path back to APPPATH) This is due to the fact that if a "foreign" model loads another "foreign" model, the alternate apppath stays consistent to successfully load those models.

Foreign Model Loading Usage:

Autoloading with Aliases:
$autoload['model'] = array('alias' => 'm_aliasmodel');
$autoload['libraries'] = array('short' => 'm_longmodelname');

Source: http://solepixel.pastebin.com/6DHpxXuz

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

Users browsing this thread:
1 Guest(s)

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.