예제 #1
0
 /**
  * Class autoloader
  * @param string $a_class Class name
  */
 public final function autoload($a_class)
 {
     $this->emit(new ZEvent($this, 'onAutoload', $a_class));
     if ($a_class[0] == 'Z') {
         $filename = strtolower(substr($a_class, 1, strlen($a_class) - 1));
         $base = Zoombi::getFrameworkDir();
         foreach (scandir($base) as $dir) {
             if ($dir[0] == '.') {
                 continue;
             }
             $path = $base . Zoombi::DS . $dir;
             if (is_dir($path) == false) {
                 continue;
             }
             $filepath = $path . Zoombi::DS . $filename . '.php';
             if (is_file($filepath)) {
                 require_once $filepath;
                 $this->emit(new ZEvent($this, 'onAutoloadSuccess', $a_class));
                 return;
             }
         }
     }
     $this->emit(new ZEvent($this, 'onAutoloadFailed', $a_class));
 }