/*
get_field_groups

@description:
@since: 3.6
@created: 27/01/13
771615
function get_field_groups( $array )
	{
		// cache
		$found = false;
		$cache = wp_cache_get( 'field_groups', 'acf', false, $found );
		
		if( $found )
		{
			return $cache;
		}
		
		
		// get acf's
		$posts = get_posts(array(
			'numberposts' 	=> -1,
			'post_type' 	=> 'acf',
			'orderby' 		=> 'menu_order title',
			'order' 		=> 'asc',
			'suppress_filters' => false,
		));

		
		// populate acfs
		if( $posts ){ foreach( $posts as $post ){
			
			 $array[] = array(
				'id' => $post->ID,
				'title' => $post->post_title,
				'menu_order' => $post->menu_order,
			);
			
		}}

		
		// set cache
		wp_cache_set( 'field_groups', $array, 'acf' );
				
				
		return $array;
	}
912750
private function getFields($field)
    {
        if ($field instanceof Group || $field instanceof Fieldset) {
            $elements = $field->getFields();
        } elseif ($field instanceof AbstractField) {
            $elements = [$field];
        } else {
            throw new \InvalidArgumentException(sprintf(
                "Invalid type '%s'",
                is_object($field) ? get_class($field) : gettype($field)
            ));
        }

        return $elements;
    }
574033
func (_m *Protocol) GetGroups() ([]common.Group, error) {
	ret := _m.Called()

	var r0 []common.Group
	if rf, ok := ret.Get(0).(func() []common.Group); ok {
		r0 = rf()
	} else {
		if ret.Get(0) != nil {
			r0 = ret.Get(0).([]common.Group)
		}
	}

	var r1 error
	if rf, ok := ret.Get(1).(func() error); ok {
		r1 = rf()
	} else {
		r1 = ret.Error(1)
	}

	return r0, r1
}
1215825
func GetGroups() (*Groups, error) {
	groups := NewGroups()
	if err := groups.GetGroups(); err != nil {
		return nil, err
	}

	return groups, nil
}
1341266
public function getallfields(){
		$res=array();
		foreach($this->categories as $cat){
			foreach($cat->groups as $group){
				foreach($group->fields as $fld){
					$res[$fld->alias]=$fld;
					}
				}
			}
		return $res;
		}
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;
   }
507264
protected function getGroups()
	{
		$groups = array();
		$label = 0;

		foreach ($this->element->children() as $element)
		{
			switch ($element->getName())
			{
				// The element is an <option />
				case 'option':
					// Initialize the group if necessary.
					if (!isset($groups[$label]))
					{
						$groups[$label] = array();
					}

					// Create a new option object based on the <option /> element.
					$tmp = HtmlSelect::option(
						($element['value']) ? (string) $element['value'] : trim((string) $element),
						Text::alt(trim((string) $element), preg_replace('/[^a-zA-Z0-9_\-]/', '_', $this->fieldname)), 'value', 'text',
						((string) $element['disabled'] == 'true')
					);

					// Set some option attributes.
					$tmp->class = (string) $element['class'];

					// Set some JavaScript option attributes.
					$tmp->onclick = (string) $element['onclick'];

					// Add the option.
					$groups[$label][] = $tmp;
					break;

				// The element is a <group />
				case 'group':
					// Get the group label.
					if ($groupLabel = (string) $element['label'])
					{
						$label = Text::_($groupLabel);
					}

					// Initialize the group if necessary.
					if (!isset($groups[$label]))
					{
						$groups[$label] = array();
					}

					// Iterate through the children and build an array of options.
					foreach ($element->children() as $option)
					{
						// Only add <option /> elements.
						if ($option->getName() != 'option')
						{
							continue;
						}

						// Create a new option object based on the <option /> element.
						$tmp = HtmlSelect::option(
							($option['value']) ? (string) $option['value'] : Text::_(trim((string) $option)),
							Text::_(trim((string) $option)), 'value', 'text', ((string) $option['disabled'] == 'true')
						);

						// Set some option attributes.
						$tmp->class = (string) $option['class'];

						// Set some JavaScript option attributes.
						$tmp->onclick = (string) $option['onclick'];

						// Add the option.
						$groups[$label][] = $tmp;
					}

					if ($groupLabel)
					{
						$label = count($groups);
					}
					break;

				// Unknown element type.
				default:
					throw new UnexpectedValueException(sprintf('Unsupported element %s in JFormFieldGroupedList', $element->getName()), 500);
			}
		}

		reset($groups);

		return $groups;
	}
1237929
@Deprecated
	public final <T extends Query> T addGroupByField(String fieldname) {
		return addGroupByField(new SimpleField(fieldname));
	}
1267878
protected function get_group_values( Field_Contract $group, $data ) {
		if ( ! $group->is_group() || ! $group->get_option( 'fields' ) ) {
			return null;
		}

		if ( ! is_array( $data ) ) {
			return null;
		}

		// We will working on clone of the $group, to prevent touching
		// on real object.
		$group = clone $group;

		$i = 0;
		$values = [];

		foreach ( array_values( $data ) as $_data ) {
			if ( ! is_array( $_data ) || empty( $_data ) ) {
				continue;
			}

			$group->index = $i;

			$fields = array_map( function ( $args ) use ( $group ) {
				return $this->config->get_field_in_group( $group, $args['id'] );
			}, $group->get_option( 'fields' ) );

			$values[ $i ] = Utils::filter_blank(
				$this->prepare_submitted_data( $fields, $_data, true )
			);

			$i++;
		}

		return array_filter( $values );
	}
902456
protected function getGroupsByNames(array $dns = [], $fields = [])
    {
        $query = $this->query->newInstance();

        return $query->newCollection($dns)->map(function ($dn) use ($query, $fields) {
            return $query->select($fields)->findByDn($dn);
        })->filter(function ($group) {
            return $group instanceof Group;
        });
    }
1198323
public function getGroups()
    {
        if(!$this->isPropertyAvailable('Groups')){
            $this->setProperty("Groups", new GroupCollection($this->getContext(), new ResourcePathEntity($this->getContext(),$this->getResourcePath(), "groups")));
        }
        return $this->getProperty("Groups");
    }
617850
def childgroup(self, field):
        
        cols = getattr(self, "cols", self.default_cols)
        width = self.num_cols / cols
        for child in field.children:
            child.width = width
        res = list(grouper(field.children, cols, fillvalue=None))
        return res
498794
public List<Group> getTopGroups() {
        if (root != null && root.getGroups() != null && root.getGroups().size() == 1) {
            return root.getGroups().get(0).getGroups();
        }
        return new ArrayList<Group>();
    }
378598
public void addGroupBy(String[] fieldNames)
    {
        for (int i = 0; i < fieldNames.length; i++)
        {
            addGroupBy(fieldNames[i]);
        }
    }
1317464
private function parseGroup()
    {
        $group = '';
        if (isset($this->parts['group']['fields'])) {
            if (is_array($this->parts['group']['fields'])) {
                $groupFields = [];
                foreach ($this->parts['group']['fields'] as $field) {
                    $field = is_array($field) ? $field : [$field];
                    $column = isset($field[0]) ? $field[0] : false;
                    $type = isset($field[1]) ? $field[1] : '';

                    $groupFields[] = $this->protect($column).($type ? ' '.strtoupper($type) : '');
                }

                $group .= implode(', ', $groupFields);
            } else {
                $group .= $this->parts['group']['fields'];
            }
        }

        if (isset($this->parts['group']['rollup']) && $this->parts['group']['rollup'] !== false) {
            $group .= ' WITH ROLLUP';
        }

        return $group;
    }
792082
public function addGroupBy($field)
    {
        $this->groupByFields = array_merge(
            $this->groupByFields,
            is_array($field) ? $field : func_get_args()
        );

        return $this;
    }
111630
public function getAsGroupedArray(): array
    {
        $result = array();

        foreach ($this->_groups as $groupName => $memberKeys) {
            $members = array();

            foreach ($memberKeys as $key) {
                $members[$key] = $this->getFieldAsArray($key);
            }

            $result[$groupName] = array(
                'group_name' => $groupName,
                'group_caption' => $this->_('group_' . $groupName),
                'fields' => $members
            );
        }

        return $result;
    }