public function setGroups(array $groups)
    {
        $this->groups = [];

        foreach ($groups as $groupIdent => $group) {
            $this->addGroup($groupIdent, $group);
        }

        uasort($this->groups, [ $this, 'sortGroupsByPriority' ]);

        // Remove items that are not active.
        $this->groups = array_filter($this->groups, function($item) {
            return ($item->active());
        });

        return $this;
    }