[Solar-talk] Ideas from a scrambled mind
Richard Thomas
lists at cyberlot.net
Mon Oct 22 15:11:21 CDT 2007
Been playing around with a few things and thought I would provide some
a possible ideas based on previous mentioned thoughts
--- Path Hints ---
The idea being that somethings you have to use third party code or
other libraries that don't follow an easy to use load format, It also
allows you to specific absolute paths which of course makes loading
files faster
handle_hints would be called on the class name being loaded before any
other load checks and allow you to skip those checks.
self::$_path_hints is an array of class and path combos
If shortcuts are enabled you can do things like
$_path_hints = array('PEAR__', '/usr/local/lib/php');
$cache = new PEAR__Cache_Lite();
Or
$_path_hints = array('Zend_','/home/site/library/zend');
Now
Zend_Controller = /home/site/library/zend/Controller.php absolute path
static private function handle_hints($class) {
$hint = null;
// The very basic of checks, If hint exists you get a path right away
if(isset(self::$_path_hints[$class])) {
$hint = self::$_path_hints[$class];
} elseif(self::$_path_shortcuts) {
// Shortcuts are enabled, first we check for path hints like PEAR__
$short = substr($class, 0, strpos($class,'__')).'__';
if(isset(self::$_path_hints[$short])) {
$hint = self::$_path_hints[$short];
// We do have a path hint, lets get rid of the extras
$class = str_replace($short, '', $class);
} else {
// No path hints are there how about library hints like Zend_
$short = substr($class, 0, strpos($class,'_')).'_';
if(isset(self::$_path_hints[$short])) {
$hint = self::$_path_hints[$short];
}
}
}
return $hint;
}
More information about the Solar-talk
mailing list