Get array of data for sort links at the header of the grid

@param $field

@return array
972384
public function getSortParams($field) {
		// Clone the filters object. If you do not do this it will be passed
		// by reference and the values will be modified!
		$filters = clone $this->getFilters(false);

		if (!$filters->has('order_by')) {
			$filters->put('order_by', '');
		}

		if (!$filters->has('order_dir')) {
			$filters->put('order_dir', 'ASC');
		}

		if ($filters['order_by'] == $field) {
			if (!$filters->has('order_dir') || $filters['order_dir'] == 'ASC') {
				$filters->put('order_dir', 'DESC');
			} else {
				$filters->put('order_dir', 'ASC');
			}
		} else {
			$filters->put('order_by', $field);
			$filters->put('order_dir', 'ASC');
		}
		
		$per_page = intval(\Illuminate\Support\Facades\Request::get('per_page', \Config::get('pagination.per_page')));
        	$per_page = $per_page > 0 ? $per_page : \Config::get('pagination.per_page');

		return ['f' => $filters->toArray(), 'page' => 1, 'per_page' => $per_page];
	}
5858
public function getHTMLFragments($gridField)
    {
        // permission check
        if (!singleton($gridField->getModelClass())->canEdit()) {
            return array();
        }

        // get uploadField
        $uploadField = $this->bulkUploadField($gridField);

        $data = ArrayData::create(array(
            'Colspan' => (count($gridField->getColumns())),
            'UploadField' => $uploadField->Field() // call ->Field() to get requirements in right order
        ));

        Requirements::javascript('colymba/gridfield-bulk-editing-tools:client/dist/js/main.js');
        Requirements::css('colymba/gridfield-bulk-editing-tools:client/dist/styles/main.css');
        Requirements::add_i18n_javascript('colymba/gridfield-bulk-editing-tools:client/lang');

        return array(
            'before' => $data->renderWith('Colymba\\BulkUpload\\BulkUploader'),
        );
    }
899535
public function get($field)
    {
        if (!is_null($this->filtered) && ! is_null($this->filtered[0])) {
            return isset($this->filtered[0][0][$field]) ? $this->filtered[0][0][$field] : null;
        }

        // Todo: Get values of entities
    }
175035
private function getFileIdsByField(array $data, string $field) : array
    {
        $result = Hash::extract($data, sprintf('%s.%s_ids', $this->table->getAlias(), $field));
        $result = empty($result) ? Hash::extract($data, sprintf('%s_ids', $field)) : $result;
        $result = array_filter((array)$result);

        return $result;
    }
676898
public function getHTMLFragments($gridField)
    {
        $fragment = ArrayData::create([
            'Link' => $this->link,
            'Caption' => $this->caption,
        ])->renderWith(__CLASS__);

        return [$this->targetFragment => $fragment];
    }
1060283
public function getIndexHeaderCells(array $fields = null)
    {
        $stub = $this->getStubContent('index.header.cell.blade', $this->template);
        $fields = $this->getFieldsToDisplay($fields);
        $rows = '';

        foreach ($fields as $field) {
            if ($field->isOnIndexView) {
                $row = $stub;
                $this->replaceFieldTitle($row, $this->getTitle($field->getLabel(), true))
                    ->replaceCommonTemplates($row, $field);
                $rows .= $row . PHP_EOL;
            }
        }

        return $rows;
    }
51344
static public function listSort($list, $field, $sort = 'asc')
    {
        if (is_array($list)) {
            $refer = array();
            $resultSet = array();
            foreach ($list as $i => $data)
                $refer[$i] = &$data[$field];
            switch ($sort) {
                case 'asc':
                    asort($refer);
                    break;
                case 'desc':
                    arsort($refer);
                    break;
            }
            foreach ($refer as $key => $val)
                $resultSet[] = &$list[$key];
            return $resultSet;
        }
        return false;
    }
473606
public function getField($field)
    {
        $result = array_filter($this->getFields(), function($input) use ($field) {
            return $field === $input->getName();
        });

        return reset($result);
    }
1186509
public function messages($field)
    {
        return (isset($this->data[$field]) && $messages = $this->data[$field]['messages']) ? $messages : array();
    }
282206
protected function getSortFields()
	{
		return array(
			'a.lft' => JText::_('JGRID_HEADING_ORDERING'),
			'a.published' => JText::_('JSTATUS'),
			'a.title' => JText::_('JGLOBAL_TITLE'),
			'a.access' => JText::_('JGRID_HEADING_ACCESS'),
			'language' => JText::_('JGRID_HEADING_LANGUAGE'),
			'a.id' => JText::_('JGRID_HEADING_ID')
		);
	}
576709
public function getHTMLFragments($gridField)
    {
        $button = new GridField_FormAction(
            $gridField, 'export_all',
            _t('GridFieldExportAllButton.LABEL', 'Export all to CSV'),
            'export_all', null
        );
        $button->setAttribute('data-icon', 'download-csv');
        $button->addExtraClass('no-ajax');
        return array(
            $this->targetFragment => '<p class="grid-csv-button">'.$button->Field().'</p>',
        );
    }
325394
public function getFieldErrors($field) {
		$existing = array_key_get($this->errors['fields'], $field['options']['name']);
		if (!empty($existing)) {
			$result = [
				'type' => null,
				'message' => '',
				'counters' => []
			];
			$sorted = [
				'danger' => [],
				'warning' => [],
				'success' => [],
				'info' => []
			];
			$types = array_keys($existing);
			if (in_array('danger', $types)) {
				$result['type'] = 'danger';
			} else {
				$temp = current($types);
				$result['type'] = $temp;
			}
			// generating text messages
			foreach ($existing as $k => $v) {
				foreach ($v as $k2 => $v2) {
					$result['counters'][$k] = ($result[$k] ?? 0) + 1;
					$sorted[$k][$k2] = $v2;
				}
			}
			foreach ($sorted as $k => $v) {
				if (empty($v)) continue;
				foreach ($v as $k2 => $v2) {
					$result['message'].= \HTML::text(['tag' => 'div', 'class' => 'numbers_field_error_messages', 'data-field_value_hash' => $k2, 'type' => $k, 'value' => $v2]);
				}
			}
			return $result;
		}
		return null;
	}
565790
public function getHTMLFragments($gridField)
    {
        $list = $gridField->getList();
        if (!$this->checkDataType($list)) {
            return null;
        }
        /** @var Sortable $list */
        $forTemplate = new ArrayData(array());
        $forTemplate->Fields = new ArrayList;

        $state = $gridField->State->GridFieldSortableHeader;
        $columns = $gridField->getColumns();
        $currentColumn = 0;

        $schema = DataObject::getSchema();
        foreach ($columns as $columnField) {
            $currentColumn++;
            $metadata = $gridField->getColumnMetadata($columnField);
            $fieldName = str_replace('.', '-', $columnField);
            $title = $metadata['title'];

            if (isset($this->fieldSorting[$columnField]) && $this->fieldSorting[$columnField]) {
                $columnField = $this->fieldSorting[$columnField];
            }

            $allowSort = ($title && $list->canSortBy($columnField));

            if (!$allowSort && strpos($columnField, '.') !== false) {
                // we have a relation column with dot notation
                // @see DataObject::relField for approximation
                $parts = explode('.', $columnField);
                $tmpItem = singleton($list->dataClass());
                for ($idx = 0; $idx < sizeof($parts); $idx++) {
                    $methodName = $parts[$idx];
                    if ($tmpItem instanceof SS_List) {
                        // It's impossible to sort on a HasManyList/ManyManyList
                        break;
                    } elseif (method_exists($tmpItem, 'hasMethod') && $tmpItem->hasMethod($methodName)) {
                        // The part is a relation name, so get the object/list from it
                        $tmpItem = $tmpItem->$methodName();
                    } elseif ($tmpItem instanceof DataObject
                        && $schema->fieldSpec($tmpItem, $methodName, DataObjectSchema::DB_ONLY)
                    ) {
                        // Else, if we've found a database field at the end of the chain, we can sort on it.
                        // If a method is applied further to this field (E.g. 'Cost.Currency') then don't try to sort.
                        $allowSort = $idx === sizeof($parts) - 1;
                        break;
                    } else {
                        // If neither method nor field, then unable to sort
                        break;
                    }
                }
            }

            if ($allowSort) {
                $dir = 'asc';
                if ($state->SortColumn(null) == $columnField && $state->SortDirection('asc') == 'asc') {
                    $dir = 'desc';
                }

                $field = GridField_FormAction::create(
                    $gridField,
                    'SetOrder' . $fieldName,
                    $title,
                    "sort$dir",
                    array('SortColumn' => $columnField)
                )->addExtraClass('grid-field__sort');

                if ($state->SortColumn(null) == $columnField) {
                    $field->addExtraClass('ss-gridfield-sorted');

                    if ($state->SortDirection('asc') == 'asc') {
                        $field->addExtraClass('ss-gridfield-sorted-asc');
                    } else {
                        $field->addExtraClass('ss-gridfield-sorted-desc');
                    }
                }
            } else {
                if ($currentColumn == count($columns)) {
                    $filter = $gridField->getConfig()->getComponentByType(GridFieldFilterHeader::class);

                    if ($filter && $filter->useLegacyFilterHeader && $filter->canFilterAnyColumns($gridField)) {
                        $field = new LiteralField(
                            $fieldName,
                            sprintf(
                                '<button type="button" name="showFilter" aria-label="%s" title="%s"' .
                                ' class="btn btn-secondary font-icon-search btn--no-text btn--icon-large grid-field__filter-open"></button>',
                                _t('SilverStripe\\Forms\\GridField\\GridField.OpenFilter', "Open search and filter"),
                                _t('SilverStripe\\Forms\\GridField\\GridField.OpenFilter', "Open search and filter")
                            )
                        );
                    } else {
                        $field = new LiteralField($fieldName, '<span class="non-sortable">' . $title . '</span>');
                    }
                } else {
                    $field = new LiteralField($fieldName, '<span class="non-sortable">' . $title . '</span>');
                }
            }
            $forTemplate->Fields->push($field);
        }

        $template = SSViewer::get_templates_by_class($this, '_Row', __CLASS__);
        return array(
            'header' => $forTemplate->renderWith($template),
        );
    }
797593
public function map(Field $field)
    {
        $values = array();

        foreach ((array)$field->value as $value) {
            $values[] = $this->convert($value);
        }

        return $values;
    }
868459
public function fetchAllOf(string $field): array
    {
        $array = [];
        foreach ($this->fetchAllGenerator() as $record) {
            $array[] = $record[$field] ?? null;
        }

        return $array;
    }
429153
public function getField($field)
    {
        return isset($this->data[$field])
            ? $this->data[$field]
            : $this->searchField($field);
    }
747206
protected function getMagentoElementSettings(array $field)
    {
        $config = array();

        if ($field['type'] === 'details') {
            $config['collapsable'] = true;
            $config['opened'] = false;
        }

        foreach ($field as $key => $value) {
            $config += $this->getMagentoProperty($key, $value, $field['type']);
        }
        return $config;
    }