Baum\SetValidator::groupRootsByScope PHP Method

groupRootsByScope() protected method

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
return 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;
    }