本文整理汇总了PHP中ezcBase::externalAutoloadArray方法的典型用法代码示例。如果您正苦于以下问题:PHP ezcBase::externalAutoloadArray方法的具体用法?PHP ezcBase::externalAutoloadArray怎么用?PHP ezcBase::externalAutoloadArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ezcBase
的用法示例。
在下文中一共展示了ezcBase::externalAutoloadArray方法的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;
}