@param FieldGroup $group
@param string     $prefix
@param FieldGroup $originGroup

@return bool
164192
public function saveGroup(FieldGroup $group, $prefix, FieldGroup $originGroup): bool
    {
        if (!Craft::$app->fields->saveGroup($group)) {
            FieldManager::error('Could not clone {name} group - {errors}.', ['name' => $originGroup->name, 'errors' => print_r($group->getErrors(), true)]);

            return false;
        }

        $errors = [];

        foreach (Craft::$app->fields->getFieldsByGroupId($originGroup->id) as $originField) {
            $field = Craft::$app->fields->createField([
                'type'                 => \get_class($originField),
                'groupId'              => $group->id,
                'name'                 => $originField->name,
                'handle'               => $prefix . $originField->handle,
                'instructions'         => $originField->instructions,
                'translationMethod'    => $originField->translationMethod,
                'translationKeyFormat' => $originField->translationKeyFormat,
                'settings'             => $originField->settings,
            ]);

            if (get_class($field) == 'craft\fields\Matrix') {
                $field->blockTypes = $this->processCloneMatrix($originField);
            }

            if (get_class($field) == 'verbb\supertable\fields\SuperTableField') {
                $field->blockTypes = $this->processCloneSuperTable($originField);
            }

            if (!FieldManager::$plugin->service->saveField($field, $originField)) {
                $errors[] = $field;
            }
        }

        if ($errors) {
            foreach ($errors as $error) {
                FieldManager::error('Could not clone {errorName} in {name} group - {errors}.', [
                    'errorName' => $error->name,
                    'name'      => $originGroup->name,
                    'errors'    => print_r($group->getErrors(), true),
                ]);

                $group->addError($error->name, 'Could not clone group.');
            }

            return false;
        }

        return true;
    }
241285
public function setPrefix(string $prefix): FieldTypeInterface
    {
        $this->prefix = $prefix;

        // Update all attached fields with the given prefix.
        foreach ($this->repository->all() as $field) {
            /** @var FieldTypeInterface $field */
            $field->setPrefix($prefix);
        }

        return $this;
    }
267006
public function hasGroup(GroupInterface $group): bool
    {
        foreach ($this->groups as $my_group) {
            if ($group->isEqualTo($my_group)) {
                return true;
            }
        }

        return false;
    }
688276
public function run($group, array $assets = [], $prefix = null)
    {
        $html = '';

        if (!isset($assets[$group]) || count($assets[$group]) == 0) {
            return $html;
        }

        is_null($prefix) || $this->path = rtrim($prefix, '/');

        foreach ($this->resolver->arrange($assets[$group]) as $data) {
            $html .= $this->asset($group, $data);
        }

        return $html;
    }
769584
public function clearGroup($group)
    {
        $success = false;
        apcu_inc($this->_config['prefix'] . $group, 1, $success);

        return $success;
    }
136487
public function addGroup(string $name, string $prefix = '', array $middlewares = [])
    {
        $this->groups[$name] = [$prefix, $middlewares];
    }
766855
public function clean($group = null)
	{
		$prefix = $this->options['hash'] . '-cache-' . $group . '-';

		foreach ($this->data as $key => $value)
		{
			if (substr($key, 0, strlen($prefix)) == $prefix)
			{
				unset($this->data[$key]);
			}
		}

		return true;
	}
737839
public function addGroup(GroupInterface $group)
	{
		if ( ! $this->inGroup($group))
		{
			$this->add('groups', $group);
		}

		return true;
	}
1166213
function recursive_groups($group, $cache_only = FALSE) {
        $this->_debug_message = "";
        $this->_warning_message = "";
        if ($group==NULL){ return (false); }

        $ret_groups=array();
        $ret_data = FALSE;

/*
    echo "DEBUG GROUP is group $group in cache ?\n";
    print_r($this->_cache_recursive_groups);
*/

        clearstatcache();
        
		if ($this->_cache_support) {
            if ("" != $this->get_cache_folder()) {
                if (file_exists($this->get_cache_folder()."ldap_rgroup_".md5($group).".cache")) {
                    if ((filemtime($this->get_cache_folder()."ldap_rgroup_".md5($group).".cache") + $this->get_cache_timeout()) > time()) {
                        if ($cache_handle = fopen($this->get_cache_folder()."ldap_rgroup_".md5($group).".cache", "rb")) {
                            $ret_groups = unserialize(fgets($cache_handle));
                            $ret_data = TRUE;
                            fclose($cache_handle);
                            @touch($this->get_cache_folder()."ldap_rgroup_".md5($group).".cache");
                        }
                    }
                }
            } elseif (isset($this->_cache_recursive_groups[$group])) {
                $ret_groups = $this->_cache_recursive_groups[$group];
                $ret_data = TRUE;
            }
        }

    	if (!$ret_data) {
            if (!$cache_only) {
    			$groups=$this->group_info($group,array($this->_group_attribute));
    			
    			// Additional test by SysCo/al
    			if (isset($groups[0][$this->_group_attribute]))
    			{
    				$groups=$groups[0][$this->_group_attribute];

    				if ($groups){
    					$group_names=$this->nice_names($groups);

    					$ret_groups=array_merge($ret_groups,$group_names); //final groups to return
    					
    					foreach ($group_names as $id => $group_name){
    						$child_groups=$this->recursive_groups($group_name);
    						$ret_groups=array_merge($ret_groups,$child_groups);
    					}
    				}
    			}
    			if ($this->_cache_support) {
                    if ("" != $this->get_cache_folder()) {
                        if (file_exists($this->get_cache_folder())) {
                            if ($cache_handle = fopen($this->get_cache_folder()."ldap_rgroup_".md5($group).".cache", "wb")) {
                                fwrite($cache_handle, serialize($ret_groups));
                                fclose($cache_handle);
                                @chmod($this->get_cache_folder()."ldap_rgroup_".md5($group).".cache", octdec($this->_linux_file_mode));
                            }
                        }
                    } else {
        				$this->_cache_recursive_groups[$group] = $ret_groups;
                    }
    			}
            } else {
                $this->_debug_message = "The requested group $group is not in cache.";
            }
        }
        return ($ret_groups);
    }
305373
public function addField($field, $fieldset = null, $group = null)
    {
        $field = FieldHelper::create($field);

        $fieldset = $fieldset ?: $this->wrap['fieldset'];
        $group = $group ?: $this->wrap['group'];

        if ($fieldset) {
            $field->setFieldset($fieldset);
        }

        if ($group) {
            $field->setGroup($group);
        }

        $group = $field->getGroup();
        $fieldset = $field->getFieldset();

        if ($group && !in_array($group, $this->groups)) {
            $this->groups[] = $group;
        }

        if ($fieldset && !in_array($fieldset, $this->fieldsets)) {
            $this->fieldsets[] = $fieldset;
        }

        $field->setControl($this->control)
            ->setForm($this);

        $this->fields[$field->getName(true)] = $field;

        return $field;
    }
1040742
public function group($fieldGroup)
    {
        //====================================================================//
        // Safety Checks ==> Verify a new Field Exists
        if (empty($this->new)) {
            Splash::log()->err("ErrFieldsNoNew");
        } else {
            //====================================================================//
            // Update New Field structure
            $this->new->group = Splash::trans(trim($fieldGroup));
        }

        return $this;
    }
502104
public function group(string $prefix, callable $callback): RouteGroup
    {
        $prefix = ($prefix === '/') ? $this->prefix : rtrim($this->prefix, '/') . sprintf('/%s', ltrim($prefix, '/'));

        $group = $this->router->group($prefix, $callback);

        // in cases of group of groups, we need to persist the settings from the previous group in the new one.
        if ($host = $this->getHost()) {
            $group->setHost($host);
        }
        if ($scheme = $this->getScheme()) {
            $group->setScheme($scheme);
        }
        if ($port = $this->getPort()) {
            $group->setPort($port);
        }
        if ($strategy = $this->getStrategy()) {
            $group->setStrategy($strategy);
        }

        // merge all the previous group middlewares in this last group.
        $group->middleware(array_merge($this->getMiddlewareStack(), $group->getMiddlewareStack()));

        return $group;
    }
45898
public function clearGroup($group)
    {
        $key = $this->_config['prefix'] . $group;
        if (isset($this->data[$key])) {
            $this->data[$key]['val'] += 1;
        }

        return true;
    }
1255499
protected function saveFields(FieldGroup $group, array $fields = [])
    {
        if (empty($fields)) {
            return false;
        }
        foreach ($fields as $field) {
            $type = $this->getFieldType($field);

            $insert = [
                'type_id'  => $type->id,
                'group_id' => $group->id
            ];

            foreach ($this->brands as $brand) {
                $this->saveField($brand, $field, $insert);
            }
        }
    }
66782
public static function group(Api\GroupCreate $group)
    {
        $fields = [];

        if ($group->getName() != null) {
            $fields['name'] = $group->getName();
        }

        if (!empty($group->getMembers())) {
            $fields['members'] = $group->getMembers();
        }

        if (!empty($group->getChildGroups())) {
            $fields['child_groups'] = $group->getChildGroups();
        }

        if ($group->getAutoUpdate() != null) {
            $fields['auto_update'] = Serialize::_groupAutoUpdateHelper(
                $group->getAutoUpdate()
            );
        }

        if (!empty($group->getTags())) {
            $fields['tags'] = $group->getTags();
        }

        return Serialize::_toJson($fields);
    }
972667
public function removeGroup(GroupInterface $group)
	{
		if ($this->inGroup($group))
		{
			$this->groups()->detach($group);
			$this->invalidateUserGroupsCache();
			$this->invalidateMergedPermissionsCache();
		}

		return true;
	}
287880
public function group($prefix, array $requirements = [], callable $groupConstructor = null)
    {
        $this->enterGroup($prefix, $requirements);

        if (null !== $groupConstructor) {
            call_user_func($groupConstructor, $this);
            $this->leaveGroup();
        }
    }