Created
October 20, 2010 15:26
-
-
Save gcoop/636631 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Interogates a target class to return the full path to that file. | |
* | |
* @param string $target Class name in Refraction convention [pkg]_[sub-pkg]_[class], which translates to [folder]/[folder]/[full target].php. | |
* | |
* @return string | |
*/ | |
static function load($target) | |
{ | |
// Explode class name and put back together with '/' for the path but leave of the last part because this is the full $target. | |
$parts = explode('_', $target); | |
$path = ''; | |
for ($i = 0; $i < (count($parts) - 1); $i++) | |
$path .= $parts[$i].'/'; | |
if (INCLUDES === null) | |
throw new Exception("You must define the absolute path to your source directory using define('INCLUDES', 'your absolute path to your source directory /src/[lib - added automatically]/[package]/FILES.')"); | |
return INCLUDES.'lib/'.$path.$target.'.php'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment