public static function lookupRecursive($packageName, array $lookupDirs = array(), $fallback = true)
{
if ($fallback) {
// Always push the PHP source directory to the end of the list for the fallback.
$lookupDirs[] = Config::getBuildDir() . DIRECTORY_SEPARATOR . Config::getCurrentPhpName() . DIRECTORY_SEPARATOR . 'ext' . DIRECTORY_SEPARATOR . $packageName;
}
foreach ($lookupDirs as $lookupDir) {
if (!file_exists($lookupDir)) {
continue;
}
if ($ext = self::createFromDirectory($packageName, $lookupDir)) {
return $ext;
}
/*
* FOLLOW_SYMLINKS is available from 5.2.11, 5.3.1
*/
$di = new RecursiveDirectoryIterator($lookupDir, RecursiveDirectoryIterator::SKIP_DOTS);
$it = new RecursiveIteratorIterator($di, RecursiveIteratorIterator::CHILD_FIRST);
/*
* Search for config.m4 or config0.m4 and use them to determine
* the directory of the extension's source, because it's not always
* the root directory in the ext archive (example xhprof)
*/
foreach ($it as $fileinfo) {
if (!$fileinfo->isDir()) {
continue;
}
if ($ext = self::createFromDirectory($packageName, $fileinfo->getPathName())) {
return $ext;
}
}
}
}