/** * 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; }