Baum\SetValidator::groupRootsByScope PHP Méthode

groupRootsByScope() protected méthode

Given a list of root nodes, it returns an array in which the keys are the array of the actual scope column values and the values are the root nodes inside that scope themselves.
protected groupRootsByScope ( mixed $roots ) : array
$roots mixed
Résultat array
    protected function groupRootsByScope($roots)
    {
        $rootsGroupedByScope = [];
        foreach ($roots as $root) {
            $key = $this->keyForScope($root);
            if (!isset($rootsGroupedByScope[$key])) {
                $rootsGroupedByScope[$key] = [];
            }
            $rootsGroupedByScope[$key][] = $root;
        }
        return $rootsGroupedByScope;
    }