Пример #1
0
function updateAutoloadCache()
{
    $pDIR = realpath(dirname(__FILE__) . '/..') . '/';
    $folders = '{lib,modules,autoload,admin_plugins,plugins,ui}/';
    $paths = implode(PATH_SEPARATOR, array_unique(findDirectoriesWithFiles($pDIR . $folders, '*.php')));
    file_put_contents(CACHE_DIR . 'path.cache', $paths);
    addPath($paths);
}
Пример #2
0
/**
 * Find all directories with files that match a given pattern
 * @param string $path Path to directory to search
 * @param string $pattern Pattern that the files should match
 * @return array A list of all the paths of the directories that contain matching files
 */
function findDirectoriesWithFiles($path, $pattern = '*')
{
    $res = array();
    if (substr($path, -1) != '/') {
        $path = $path . '/';
    }
    foreach (glob($path . $pattern, GLOB_BRACE) as $file) {
        $res[] = dirname($file);
    }
    foreach (glob($path . '*', GLOB_ONLYDIR | GLOB_BRACE) as $file) {
        $res = array_merge($res, findDirectoriesWithFiles($file, $pattern));
    }
    return $res;
}