Beispiel #1
0
 /**
  * Handles autoloading of classes.
  *
  * @param string $class A class name.
  *
  * @return bool Returns true if the class has been loaded
  */
 public static function autoload($class)
 {
     // class already exists
     if (self::classExists($class)) {
         return true;
     }
     $force = false;
     $lowerClass = strtolower($class);
     if (isset(self::$classes[$lowerClass])) {
         // we have a class path for the class, let's include it
         if (is_readable(self::$classes[$lowerClass])) {
             require_once self::$classes[$lowerClass];
             if (self::classExists($class)) {
                 return true;
             }
         }
         // there is a class path in cache, but the file does not exist or does not contain the class any more
         // but maybe the class exists in another already known file now
         // so all files have to be analysed again => $force reload
         $force = true;
         unset(self::$classes[$lowerClass]);
         self::$cacheChanged = true;
     }
     // Return true if class exists after calling $composerLoader
     if (self::$composerLoader->loadClass($class) && self::classExists($class)) {
         return true;
     }
     // Class not found, so reanalyse all directories if not already done or if $force==true
     // but only if an admin is logged in
     if ((!self::$reloaded || $force) && ($user = rex_backend_login::createUser()) && $user->isAdmin()) {
         self::reload($force);
         return self::autoload($class);
     }
     return false;
 }