Sub-groups are used to define collections of repeatable fields which can be
inserted, deleted and re-ordered by the user.

@param Agencms\Core\Group ...$groups
@return Agencms\Core\Group
769774
public function addGroup(Group ...$groups)
    {
        collect($groups)->map(function ($group) {
            $this->group['groups'][] = $group->get();
        });

        return $this;
    }
484049
public function fields($fields)
    {
        if (is_array($fields) || $fields === null) {
            $this->fields = $fields;
        } else {
            $this->fields = func_get_args();
        }
        return $this;
    }
545293
public function setGroup($group)
    {
        $this->fieldName = null;

        $group = str_replace('.', '/', $group);

        $this->group = $group;

        return $this;
    }
1278244
public function setSubnodes(\Doctrine\Common\Collections\ArrayCollection $subnodes)
    {
        $this->subnodes = $subnodes;

        return $this;
    }
387917
final public function groupBy($fields) {
      if (func_num_args()>0) {
         if (func_num_args()==1) {
            if (!is_array($fields)) {
               $fields = (array) $fields;
            }
         }else{
            $fields = func_get_args();
         }

         $this->groupBy = " GROUP BY ".implode(',',$fields);

         $this->find_first_data = $this->find_save_data = $this->find_delete_data = FALSE;
         
         $this->get_instance();
         return $this;
      }
      return null;
   }
929418
public function removeField($name, $group = null)
    {
        if ($group) {
            $name = $group . '/' . $name;
        }

        if (isset($this->fields[$name])) {
            unset($this->fields[$name]);
        }

        return $this;
    }
430069
public function &serialize(...$fields)
    {
        if (!empty($fields)) {
            $this->serialize = array_unique(array_merge($this->serialize, $fields));
        }

        return $this;
    }
160686
public function hasGroups($groups)
    {
        if ($this->user() === null) {
            return null;
        }

        if (!is_array($groups)) {
            $groups = func_get_args();
        }

        // Count roles because user need user to have all roles passed as parameter
        return count(array_intersect($groups, $this->groups)) === count($groups);
    }
428221
public function addGroup($group)
    {
        if ($this->groups === null) {
            $this->setGroups($this->groupRepository->getAllByRevision($this));
        }
        $this->groups[] = $group;
        return $this;
    }
8388
public function FieldHolder($properties = [])
    {
        return FieldGroup::create(
            $this->Title(),
            $this->Fields
        )->addExtraClass('dimensions')->FieldHolder($properties);
    }
411391
public function updateGroup(array $groups)
    {
        $groups = json_encode($groups, JSON_UNESCAPED_UNICODE);

        return $this->auth(function () use ($groups) {
            return $this->http->postJson(
                $this->baseUrl . 'cgi-bin/groups/update?access_token=' . $this->accessToken,
                $groups
            );
        });
    }
158967
public function addGroup($group)
    {
        if (null === $this->groups) {
            $this->groups = [];
        }
        if (!in_array($group, $this->groups)) {
            $this->groups[] = $group;
        }

        return $this;
    }
1343160
public function addApplicationGroups(ApplicationGroup ...$groups)
    {
        foreach ($groups as $group) {
            $this->getApplicationGroups()->add($group);
        }

        return $this;
    }
640928
public function setGroups($groups=null) {
		if(!is_array($groups) && $groups !== null)
			$groups = [$groups];
		$this->groups = $groups;
		return $this;
	}
182089
public function setGroup($group)
    {
        if (!empty($group)) {
            $this->query['group'] = $group;
        } else {
            unset($this->query['group']);
        }
        return $this;
    }
367993
protected function group($group)
    {
        return $this->dispatcher->run($group, $this->assets, $this->path);
    }
701824
public function removeFields($fieldset = null, $group = null)
    {
        foreach ($this->fields as $current) {
            if ($fieldset && $current->getFieldset() != $fieldset) {
                $this->removeField($current->getName(true));
            }

            if ($group && $current->getGroup() != $group) {
                $this->removeField($current->getName(true));
            }
        }

        return $this;
    }