Jarves\Storage\FileStorage::getBranch PHP Метод

getBranch() публичный Метод

{@inheritDoc}
public getBranch ( $pk = null, Condition $condition = null, $depth = 1, $scope = null, $options = null )
$condition Jarves\Configuration\Condition
    public function getBranch($pk = null, Condition $condition = null, $depth = 1, $scope = null, $options = null)
    {
        if ($pk) {
            $path = $this->getPathFromPK($pk);
        } else {
            $path = '/';
        }
        if ($depth === null) {
            $depth = 1;
        }
        try {
            $files = $this->webFilesystem->getFiles($path);
        } catch (NotADirectoryException $e) {
            return null;
        }
        $c = 0;
        //        $offset = $options['offset'];
        //        $limit = $options['limit'];
        $result = array();
        $blacklistedFiles = array();
        $showHiddenFiles = false;
        //todo
        foreach ($files as $file) {
            $file = $file->toArray();
            if (isset($blacklistedFiles[$file['path']]) | (!$showHiddenFiles && substr($file['name'], 0, 1) == '.')) {
                continue;
            }
            if ($condition && $condition->hasRules() && !$condition->satisfy($file, 'jarves/file')) {
                continue;
            }
            $file['writeAccess'] = $this->acl->isUpdatable('jarves/file', array('path' => $file['path']));
            $c++;
            //            if ($offset && $offset >= $c) {
            //                continue;
            //            }
            //            if ($limit && $limit < $c) {
            //                break;
            //            }
            if ($depth > 0) {
                $children = array();
                if ($file['type'] == 'dir') {
                    try {
                        $children = self::getBranch(array('path' => $file['path']), $condition, $depth - 1);
                    } catch (FileNotFoundException $e) {
                        $children = null;
                    }
                }
                $file['_childrenCount'] = count($children);
                if ($depth > 1 && $file['type'] == 'dir') {
                    $file['_children'] = $children;
                }
            }
            $result[] = $file;
        }
        return $result;
    }