當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ezcBase::loadExternalFile方法代碼示例

本文整理匯總了PHP中ezcBase::loadExternalFile方法的典型用法代碼示例。如果您正苦於以下問題:PHP ezcBase::loadExternalFile方法的具體用法?PHP ezcBase::loadExternalFile怎麽用?PHP ezcBase::loadExternalFile使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ezcBase的用法示例。


在下文中一共展示了ezcBase::loadExternalFile方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: requireFile

 /**
  * Tries to load the autoload array and, if loaded correctly, includes the class.
  *
  * @param string $fileName    Name of the autoload file.
  * @param string $className   Name of the class that should be autoloaded.
  * @param string $prefix      The prefix of the class repository.
  *
  * @return bool  True is returned when the file is correctly loaded.
  *                   Otherwise false is returned.
  */
 protected static function requireFile($fileName, $className, $prefix)
 {
     $autoloadDir = ezcBase::$packageDir . "autoload/";
     // We need the full path to the fileName. The method file_exists() doesn't
     // automatically check the (php.ini) library paths. Therefore:
     // file_exists( "ezc/autoload/$fileName" ) doesn't work.
     if ($prefix === 'ezc' && file_exists("{$autoloadDir}{$fileName}")) {
         $array = (require "{$autoloadDir}{$fileName}");
         if (is_array($array) && array_key_exists($className, $array)) {
             // Add the array to the cache, and include the requested file.
             ezcBase::$autoloadArray = array_merge(ezcBase::$autoloadArray, $array);
             if (ezcBase::$options !== null && ezcBase::$options->preload && !preg_match('/Exception$/', $className)) {
                 foreach ($array as $loadClassName => $file) {
                     if ($loadClassName !== 'ezcBase' && !class_exists($loadClassName, false) && !interface_exists($loadClassName, false) && !preg_match('/Exception$/', $loadClassName)) {
                         ezcBase::loadFile(ezcBase::$autoloadArray[$loadClassName]);
                     }
                 }
             } else {
                 ezcBase::loadFile(ezcBase::$autoloadArray[$className]);
             }
             return true;
         }
     }
     // It is not in components autoload/ dir.
     // try to search in additional dirs.
     foreach (ezcBase::$repositoryDirs as $repositoryPrefix => $extraDir) {
         if (gettype($repositoryPrefix) === 'string' && $repositoryPrefix !== $prefix) {
             continue;
         }
         if (file_exists($extraDir['autoloadDirPath'] . '/' . $fileName)) {
             $array = array();
             $originalArray = (require $extraDir['autoloadDirPath'] . '/' . $fileName);
             // Building paths.
             // Resulting path to class definition file consists of:
             // path to extra directory with autoload file +
             // basePath provided for current extra directory +
             // path to class definition file stored in autoload file.
             foreach ($originalArray as $class => $classPath) {
                 $array[$class] = $extraDir['basePath'] . '/' . $classPath;
             }
             if (is_array($array) && array_key_exists($className, $array)) {
                 // Add the array to the cache, and include the requested file.
                 ezcBase::$externalAutoloadArray = array_merge(ezcBase::$externalAutoloadArray, $array);
                 ezcBase::loadExternalFile(ezcBase::$externalAutoloadArray[$className]);
                 return true;
             }
         }
     }
     // Nothing found :-(.
     return false;
 }
開發者ID:humansky,項目名稱:qframe,代碼行數:61,代碼來源:base.php


注:本文中的ezcBase::loadExternalFile方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。