/framework/ZoopLoader.php

http://zoop.googlecode.com/ · PHP · 42 lines · 28 code · 6 blank · 8 comment · 4 complexity · da728339ee208cd84071af7be6497453 MD5 · raw file

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