From: <tr...@us...> - 2012-12-05 19:14:03
|
Revision: 10319 http://sourceforge.net/p/xoops/svn/10319 Author: trabis Date: 2012-12-05 19:14:00 +0000 (Wed, 05 Dec 2012) Log Message: ----------- Allowing modules/preloads/etc to add their own classes using maps Modified Paths: -------------- XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsload.php Modified: XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsload.php =================================================================== --- XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsload.php 2012-12-04 20:08:57 UTC (rev 10318) +++ XoopsCore/branches/2.6.x/2.6.0/htdocs/class/xoopsload.php 2012-12-05 19:14:00 UTC (rev 10319) @@ -25,6 +25,33 @@ class XoopsLoad { /** + * holds classes name and classes paths + * + * @var array + */ + static protected $map = array(); + + /** + * Allow modules/preloads/etc to add their own maps + * Use XoopsLoad::addMap(array('classname', 'path/to/class'); + * + * @param array $map + * + * @return array + */ + static function addMap(array $map) { + XoopsLoad::$map = array_merge(XoopsLoad::$map, $map); + return XoopsLoad::$map; + } + + /** + * @return array + */ + static function getMap() { + return XoopsLoad::$map; + } + + /** * @static * * @param string $name @@ -88,14 +115,10 @@ */ static private function loadCore($name) { - static $configs; - - if (!isset($configs)) { - $configs = XoopsLoad::loadCoreConfig(); - } - if (isset($configs[$name])) { + $map = XoopsLoad::addMap(XoopsLoad::loadCoreConfig()); + if (isset($map[$name])) { //attempt loading from map - require $configs[$name]; + require $map[$name]; if (class_exists($name) && method_exists($name, '__autoload')) { call_user_func(array($name, '__autoload')); } @@ -118,7 +141,7 @@ * * @static * @param string $name - * @return false|string + * @return bool|string */ static private function loadFramework($name) { |