elFinder::ensureDirsRecursively PHP Метод

ensureDirsRecursively() защищенный Метод

Ensure directories recursively
Автор: Naoki Sawada
protected ensureDirsRecursively ( object $volume, string $target, string $dirs, string $path = '' ) : array | false
$volume object Volume object
$target string Target hash
$dirs string Array of directory tree to ensure
$path string Relative path form target hash
Результат array | false array('stats' => array([stat of maked directory]), 'hashes' => array('[path]' => '[hash]'))
    protected function ensureDirsRecursively($volume, $target, $dirs, $path = '')
    {
        $res = array('stats' => array(), 'hashes' => array());
        foreach ($dirs as $name => $sub) {
            $name = (string) $name;
            if (($parent = $volume->realpath($target)) && ($dir = $volume->dir($volume->getHash($parent, $name))) || ($dir = $volume->mkdir($target, $name))) {
                $_path = $path . '/' . $name;
                $res['stats'][] = $dir;
                $res['hashes'][$_path] = $dir['hash'];
                if (count($sub)) {
                    if ($subRes = $this->ensureDirsRecursively($volume, $dir['hash'], $sub, $_path)) {
                        $res = array_merge_recursive($res, $subRes);
                    } else {
                        return false;
                    }
                }
            } else {
                return false;
            }
        }
        return $res;
    }