本文整理汇总了PHP中ezcBase::requireFile方法的典型用法代码示例。如果您正苦于以下问题:PHP ezcBase::requireFile方法的具体用法?PHP ezcBase::requireFile怎么用?PHP ezcBase::requireFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ezcBase
的用法示例。
在下文中一共展示了ezcBase::requireFile方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: autoload
/**
* Tries to autoload the given className. If the className could be found
* this method returns true, otherwise false.
*
* This class caches the requested class names (including the ones who
* failed to load).
*
* @param string $className The name of the class that should be loaded.
*
* @return bool
*/
public static function autoload($className)
{
ezcBase::setPackageDir();
// Check whether the classname is already in the cached autoloadArray.
if (array_key_exists($className, ezcBase::$autoloadArray)) {
// Is it registered as 'unloadable'?
if (ezcBase::$autoloadArray[$className] == false) {
return false;
}
ezcBase::loadFile(ezcBase::$autoloadArray[$className]);
return true;
}
// Check whether the classname is already in the cached autoloadArray
// for external repositories.
if (array_key_exists($className, ezcBase::$externalAutoloadArray)) {
// Is it registered as 'unloadable'?
if (ezcBase::$externalAutoloadArray[$className] == false) {
return false;
}
ezcBase::loadExternalFile(ezcBase::$externalAutoloadArray[$className]);
return true;
}
// Not cached, so load the autoload from the package.
// Matches the first and optionally the second 'word' from the classname.
$fileNames = array();
if (preg_match("/^([a-z0-9]*)([A-Z][a-z0-9]*)([A-Z][a-z0-9]*)?/", $className, $matches) !== false) {
$autoloadFile = "";
// Try to match with both names, if available.
switch (sizeof($matches)) {
case 4:
// check for x_y_autoload.php
$autoloadFile = strtolower("{$matches[2]}_{$matches[3]}_autoload.php");
$fileNames[] = $autoloadFile;
if (ezcBase::requireFile($autoloadFile, $className, $matches[1])) {
return true;
}
// break intentionally missing.
// break intentionally missing.
case 3:
// check for x_autoload.php
$autoloadFile = strtolower("{$matches[2]}_autoload.php");
$fileNames[] = $autoloadFile;
if (ezcBase::requireFile($autoloadFile, $className, $matches[1])) {
return true;
}
// check for autoload.php
$autoloadFile = 'autoload.php';
$fileNames[] = $autoloadFile;
if (ezcBase::requireFile($autoloadFile, $className, $matches[1])) {
return true;
}
break;
}
// Maybe there is another autoload available.
// Register this classname as false.
ezcBase::$autoloadArray[$className] = false;
}
$path = ezcBase::$packageDir . 'autoload/';
$realPath = realpath($path);
if ($realPath == '') {
// Can not be tested, because if this happens, then the autoload
// environment has not been set-up correctly.
trigger_error("Couldn't find autoload directory '{$path}'", E_USER_ERROR);
}
$dirs = self::getRepositoryDirectories();
if (ezcBase::$options && ezcBase::$options->debug) {
throw new ezcBaseAutoloadException($className, $fileNames, $dirs);
}
return false;
}