Пример #1
0
function myAutoLoad($classname)
{
    if (strpos($classname, "QFrame") === 0) {
        QFrameLoader::loadClass($classname);
    } else {
        $classpath = getClassPath();
        if (isset($classpath[$classname])) {
            include $classpath[$classname];
        }
    }
}
Пример #2
0
 /**
  * Callback for class autoloading.
  *
  * @param string $class
  * @return AutoLoader
  */
 public function autoload($class)
 {
     $class = str_replace("\\", "_", $class);
     $class = getClassPath($class);
     $classFile = array();
     $classFile[] = $class . ".php";
     $classFile[] = "Util/" . $class . ".util.php";
     if ($file = file_exists_inc($classFile)) {
         require_once $file;
     }
     return $this;
 }
Пример #3
0
                    $module = "modules/{$match[0]}/{$match[2]}s/{$match[1]}.php";
                }
                if (is_file(APP_PATH . $module)) {
                    return APP_PATH . $module;
                } elseif (is_file(ROOT_PATH . $module)) {
                    return ROOT_PATH . $module;
                }
            }
        }
    }
    return null;
}
/**
 * โหลดคลาสโดยอัตโนมัติตามชื่อของ Classname เมื่อมีการเรียกใช้งานคลาส
 * PSR-4
 *
 * @param string $className
 */
spl_autoload_register(function ($className) {
    $file = getClassPath($className);
    if ($file !== null) {
        require $file;
    }
});
/**
 * load base class
 */
require VENDOR_DIR . 'KBase.php';
require VENDOR_DIR . 'Kotchasan.php';
require VENDOR_DIR . 'Config.php';
require VENDOR_DIR . 'Http/Request.php';
Пример #4
0
 /**
  * Internal class factory to search for extensions.
  *
  * @param string $class	Class path
  * @param array $args
  *
  * @return object|boolean	Object of the class
  */
 public static function factory($class, $args = array())
 {
     if (isset(self::$rewriteCache[$class])) {
         $class = self::$rewriteCache[$class];
         return new $class($args);
     }
     $classKey = $class;
     $class = self::rewrite($class);
     $class = getClassPath($class, "/", "_");
     if (!class_exists($class, false)) {
         foreach (self::$namespace as $namespace) {
             $_class = $namespace . "_" . $class;
             if (class_exists($_class)) {
                 self::$rewriteCache[$classKey] = $_class;
                 return new $_class($args);
             }
         }
     } else {
         self::$rewriteCache[$classKey] = $class;
         return new $class($args);
     }
     return false;
 }