Gaufrette\Adapter\PhpseclibSftp::fetchKeys PHP Method

fetchKeys() protected method

protected fetchKeys ( $directory = '', $onlyKeys = true )
    protected function fetchKeys($directory = '', $onlyKeys = true)
    {
        $keys = array('keys' => array(), 'dirs' => array());
        $list = $this->sftp->rawlist($this->computePath($directory));
        foreach ((array) $list as $filename => $stat) {
            if ('.' === $filename || '..' === $filename) {
                continue;
            }
            $path = ltrim($directory . '/' . $filename, '/');
            if (isset($stat['type']) && $stat['type'] === NET_SFTP_TYPE_DIRECTORY) {
                $keys['dirs'][] = $path;
            } else {
                $keys['keys'][] = $path;
            }
        }
        $dirs = $keys['dirs'];
        if ($onlyKeys && !empty($dirs)) {
            $keys['keys'] = array_merge($keys['keys'], $dirs);
            $keys['dirs'] = array();
        }
        foreach ($dirs as $dir) {
            $keys = array_merge_recursive($keys, $this->fetchKeys($dir, $onlyKeys));
        }
        return $keys;
    }