diff --git a/library/Nmc.php b/library/Nmc.php index 6e005383d3ae375b73c339d2604bcd62ea25b871..4d5b5c083de9494e1e8e49871b5458b0abd764f3 100644 --- a/library/Nmc.php +++ b/library/Nmc.php @@ -15,6 +15,36 @@ class Nmc extends Nmc_Friendly echo "ha ha!"; return parent::__get($key); } + + static public function loadApplicationClass($class, $dirs = null) + { + $nameParts = explode('_', $class); + if($nameParts[0] != 'Application') { + throw new Nmc_Exception('Not an Application Class.'); + } + + if (class_exists($class, false)) { + return; + } + + // autodiscover the path from the class name + $path = str_replace('_', DIRECTORY_SEPARATOR, $class); + $path = substr($path, 12); + if ($dirs === null && $path != $class) { + // use the autodiscovered path + $dirs = dirname($path); + $file = basename($path) . '.php'; + } else { + $file = $class . '.php'; + } + + self::loadFile($file, $dirs, true); + + if (!class_exists($class, false)) { + throw new Zend_Exception("File \"$file\" was loaded " + . "but class \"$class\" was not found within."); + } + } } ?> \ No newline at end of file