Skip to content

Instantly share code, notes, and snippets.

@gcoop
Created October 20, 2010 15:26
Show Gist options
  • Save gcoop/636631 to your computer and use it in GitHub Desktop.
Save gcoop/636631 to your computer and use it in GitHub Desktop.
/**
* 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