PageRenderTime 11ms CodeModel.GetById 1ms app.highlight 4ms RepoModel.GetById 2ms app.codeStats 0ms

/framework/ZoopLoader.php

http://zoop.googlecode.com/
PHP | 42 lines | 28 code | 6 blank | 8 comment | 4 complexity | da728339ee208cd84071af7be6497453 MD5 | raw file
 1<?php
 2class ZoopLoader
 3{
 4	static private $classes = array();
 5	
 6	static public function addClass($classname, $filename)
 7	{
 8		self::$classes[strtolower($classname)] = $filename;
 9	}
10	
11	static private function getClassPath($className)
12	{
13		$className = strtolower($className);
14		if(isset(self::$classes[$className]))
15			return self::$classes[$className];
16		
17		return false;
18	}
19	
20	/**
21	 * Automatic class loading handler.  This automatically loads a class using the path
22	 * information that was registered using the ZoopLoader::class method 
23	 *
24	 * @param string $className Name of the class to load
25	 */
26	static function autoload($className)
27	{
28		$classPath = ZoopLoader::getClassPath($className);
29		if($classPath)
30			require_once($classPath);
31	
32		if(substr($className, 0, 5) == 'Zend_')
33		{
34			// $parts = explode('_', $className);
35			// $modName = $parts[1];
36			$shortPath = str_replace('_', '/', $className);
37			require_once(zoop_dir . "/vendor/zend/$shortPath.php");
38		}
39	}
40}
41
42spl_autoload_register(array('ZoopLoader', 'autoload'));