예제 #1
0
 public static function loadClassMapFromCache()
 {
     if (self::$_classMap) {
         return true;
     }
     if (!file_exists(self::$_classMapFileLocation)) {
         return false;
     }
     // if cached map was not loaded but exists on the disk, load it
     self::$_classMap = unserialize(file_get_contents(self::$_classMapFileLocation));
     if (!is_array(self::$_classMap)) {
         $permission = substr(decoct(fileperms(self::$_classMapFileLocation)), 2);
         error_log("PHP Class map could not be loaded from path [" . self::$_classMapFileLocation . "] file permissions [{$permission}]");
         die('PHP Class map could not be loaded');
     }
     return true;
 }
 /**
  * Load and cache the class map
  */
 private static function loadClassMap()
 {
     if (!self::$_classMapFileLocation || !file_exists(self::$_classMapFileLocation) || self::$_noCache == true) {
         // cached map doesn't exists, rebuild the cache map
         foreach (self::$_classPath as $dir) {
             if (strpos($dir, DIRECTORY_SEPARATOR . "*") == strlen($dir) - 2) {
                 $dir = substr($dir, 0, strlen($dir) - 2);
                 $recursive = true;
             } else {
                 $recursive = false;
             }
             self::scanDirectory($dir, $recursive);
         }
         if (self::$_noCache === false && self::$_classMapFileLocation) {
             // save the cached map
             $bytesWritten = file_put_contents(self::$_classMapFileLocation, serialize(self::$_classMap));
             if (!$bytesWritten) {
                 $folderPermission = substr(decoct(fileperms(dirname(self::$_classMapFileLocation))), 2);
                 error_log("PHP Class map could not be saved to path [" . self::$_classMapFileLocation . "] folder permisisons [{$folderPermission}]");
                 die("PHP Class map could not be saved");
             }
         }
     } else {
         if (count(self::$_classMap) == 0) {
             // if cached map was not loaded but exists on the disk, load it
             self::$_classMap = unserialize(file_get_contents(self::$_classMapFileLocation));
             if (!is_array(self::$_classMap)) {
                 $permission = substr(decoct(fileperms(self::$_classMapFileLocation)), 2);
                 error_log("PHP Class map could not be loaded from path [" . self::$_classMapFileLocation . "] file permisisons [{$permission}]");
                 die('PHP Class map could not be loaded');
             }
         }
     }
 }
예제 #3
0
 /**
  * Load and cache the class map
  */
 private static function loadClassMap()
 {
     if (!file_exists(self::$_classMapFileLocation) || self::$_noCache == true) {
         // cached map doesn't exists, rebuild the cache map
         foreach (self::$_classPath as $dir) {
             if (strpos($dir, DIRECTORY_SEPARATOR . "*") == strlen($dir) - 2) {
                 $dir = substr($dir, 0, strlen($dir) - 2);
                 $recursive = true;
             } else {
                 $recursive = false;
             }
             self::scanDirectory($dir, $recursive);
         }
         if (self::$_noCache === false) {
             // save the cached map
             file_put_contents(self::$_classMapFileLocation, serialize(self::$_classMap));
         }
     } else {
         if (count(self::$_classMap) == 0) {
             // if cached map was not loaded but exists on the disk, load it
             self::$_classMap = unserialize(file_get_contents(self::$_classMapFileLocation));
         }
     }
 }