set/override entries to gridelements container

@param array $fieldArray
776162
public function setFieldEntriesForGridContainers(array &$fieldArray)
    {
        if ((int)$fieldArray['tx_gridelements_container'] > 0 && isset($fieldArray['colPos']) && (int)$fieldArray['colPos'] !== -1) {
            $fieldArray['colPos'] = -1;
            $fieldArray['tx_gridelements_columns'] = 0;
            $targetContainer = BackendUtility::getRecord(
                'tt_content',
                (int)$fieldArray['tx_gridelements_container'],
                'sys_language_uid'
            );
            if ((int)$targetContainer['sys_language_uid'] > -1) {
                $fieldArray['sys_language_uid'] = (int)$targetContainer['sys_language_uid'];
            }
        } else {
            if (isset($fieldArray['tx_gridelements_container']) && (int)$fieldArray['tx_gridelements_container'] === 0 && (int)$fieldArray['colPos'] === -1) {
                $fieldArray['colPos'] = $this->checkForRootColumn((int)$this->getContentUid());
                $fieldArray['tx_gridelements_columns'] = 0;
                $fieldArray['tx_gridelements_container'] = 0;
            } else {
                if (!isset($fieldArray['sys_language_uid']) && isset($fieldArray['tx_gridelements_container']) && (int)$fieldArray['tx_gridelements_container'] > 0 && (int)$fieldArray['colPos'] === -1) {
                    $targetContainer = BackendUtility::getRecord(
                        'tt_content',
                        (int)$fieldArray['tx_gridelements_container'],
                        'sys_language_uid'
                    );
                    if ((int)$targetContainer['sys_language_uid'] > -1) {
                        $fieldArray['sys_language_uid'] = (int)$targetContainer['sys_language_uid'];
                    }
                }
            }
        }
        if (isset($targetContainer) && (int)$targetContainer['sys_language_uid'] === -1) {
            $list = array_flip(GeneralUtility::trimExplode(
                ',',
                $GLOBALS['TCA']['tt_content']['ctrl']['copyAfterDuplFields'],
                true
            ));
            unset($list['sys_language_uid']);
            $GLOBALS['TCA']['tt_content']['ctrl']['copyAfterDuplFields'] = implode(',', array_flip($list));
        }
    }
963194
void setFields(Field[] fields) {
    this.fields = fields;
    this.resultSetColumnNameIndexMap = null;
    this.cachedMaxResultRowSize = null;
    this.needUpdateFieldFormats = fields != null;
    this.hasBinaryFields = false; // just in case
  }
580165
public function array_fields($array, array $fields){
        $newArray= array();
        foreach ($array as $value) {
            $newValue= array();
            foreach ($fields as $key) {
                if(array_key_exists($key, $value)){
                    $newValue[$key]= $value[$key];
                }
            }
            $newArray[]= $newValue;
        }        
        return $newArray;
    }
765815
private void setFields(Map<String, FieldType> map, MapRow row, FieldContainer container)
   {
      if (row != null)
      {
         for (Map.Entry<String, FieldType> entry : map.entrySet())
         {
            container.set(entry.getValue(), row.getObject(entry.getKey()));
         }
      }
   }
641489
protected function filterElements(array &$elements): void
    {
        if (!empty($elements['storage_key'])) {
            $this->_storage['storage_key'] = trim($elements['storage_key']);
        }
        if (!empty($elements['storage_timestamp'])) {
            $this->_storage['storage_timestamp'] = (int)$elements['storage_timestamp'];
        }

        unset ($elements['storage_key'], $elements['storage_timestamp'], $elements['_post_entries_save']);
    }
141574
public function updateCMSFields(FieldList $fields)
    {
        // Update Field Objects (from parent):
        
        parent::updateCMSFields($fields);
        
        // Create Page Types Grid Field:
        
        $types = GridField::create(
            'AppPageTypes',
            $this->owner->fieldLabel('AppPageTypes'),
            $this->owner->AppPageTypes(),
            GridFieldConfig_RecordEditor::create()
        );
        
        // Create Page Types Tab:
        
        $fields->findOrMakeTab('Root.SilverWare.PageTypes', $this->owner->fieldLabel('AppPageTypes'));
        
        // Add Grid Field to Page Types Tab:
        
        $fields->addFieldToTab('Root.SilverWare.PageTypes', $types);
    }
1142261
public function setChannelElementsFromArray(array $elementArray)
    {
        foreach ($elementArray as $elementName => $content) {
            $this->setChannelElement($elementName, $content);
        }

        return $this;
    }
540715
public function setPostfields(array $array)
    {
        if (!is_null($this->getGetfield())) 
        { 
            throw new Exception('You can only choose get OR post fields.'); 
        }
        
        if (isset($array['status']) && substr($array['status'], 0, 1) === '@')
        {
            $array['status'] = sprintf("\0%s", $array['status']);
        }
        
        $this->postfields = $array;
        
        return $this;
    }
719837
protected function namespaceFields(FieldList $fields, array $context)
    {
        $elementID = $context['Record']->ID;

        foreach ($fields->dataFields() as $field) {
            $namespacedName = sprintf(self::FIELD_NAMESPACE_TEMPLATE, $elementID, $field->getName());
            $field->setName($namespacedName);
        }
    }
1203324
public function fillFieldWithValue(string $fieldName, array $value): void
    {
        $fieldElement = $this->getField($fieldName);
        $fieldElement->setValue($value);
    }
530938
public function setFields(array $fields)
    {
        parent::setFields($fields);
        if (empty($this->batchId)) {
            $this->batchId = null;
        }

        if (isset($fields['_embedded']['messages'])) {
            $this->messages = $fields['_embedded']['messages'];
        }
    }
860716
private function _fromAssociativeArray(array $array)
    {
        foreach ($this->_fields as $fieldName => $field) {
            $fieldType = $field['FieldType'];   
            if (is_array($fieldType)) {
                if ($this->_isComplexType($fieldType[0])) {
                    if (array_key_exists($fieldName, $array)) { 
                        $elements = $array[$fieldName];
                        if (!$this->_isNumericArray($elements)) {
                            $elements =  array($elements);    
                        }
                        if (count ($elements) >= 1) {
                            require_once (dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . str_replace('_', DIRECTORY_SEPARATOR, $fieldType[0]) . ".php");

                            foreach ($elements as $element) {
                                $this->_fields[$fieldName]['FieldValue'][] = new $fieldType[0]($element);
                            }
                        }
                    } 
                } else {
                    if (array_key_exists($fieldName, $array)) {
                        $elements = $array[$fieldName];
                        if (!$this->_isNumericArray($elements)) {
                            $elements =  array($elements);    
                        }
                        if (count ($elements) >= 1) {
                            foreach ($elements as $element) {
                                $this->_fields[$fieldName]['FieldValue'][] = $element;
                            }
                        }  
                    }
                }
            } else {
                 if ($this->_isComplexType($fieldType)) {
                    if (array_key_exists($fieldName, $array)) {
                        require_once (dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . str_replace('_', DIRECTORY_SEPARATOR, $fieldType) . ".php");
                        $this->_fields[$fieldName]['FieldValue'] = new $fieldType($array[$fieldName]);
                    }   
                 } else {
                    if (array_key_exists($fieldName, $array)) {
                        $this->_fields[$fieldName]['FieldValue'] = $array[$fieldName];
                    }
                 }
            }
        }
    }
978520
public function setCustomElements(array $customElements)
    {
        $this->customElements = array();

        foreach ($customElements as $element) {
            $this->addCustomElement($element);
        }

        return $this;
    }
408111
function setFieldValuesNestedArray (field, items) {
    // do not process unless value
    if (!defined(items)) {
        return
    }
    // property value must be array of items
    assert.ok(Array.isArray(items), 'expected array for '+field.property)
    // index of item in values array
    var idx = 0
    // create entry in field values for each item in array
    _.each(items, item => {
        // index string for field name
        var nameIdx = '['+idx+']'
        // each entry in values is an array of fields with values
        var values = []
        // add each sub field to values with value from record item
        _.each(field.fields, field => {
            // clone field to change properties for local version
            field = _.cloneDeep(field)
            // set value from item
            setFieldValue(item, field)
            // replace index in field name
            field.name = field.name.replace('[0]', nameIdx)
            // add field to list of values for item
            values.push(field)
        })
        // add row to values
        field.values.push(values)
        // increment row count
        idx++
    })
    // get index string for new row
    var nameIdx = '['+idx+']'
    // update row index for field names that will be used for a new row
    _.each(field.fields, field => {
        field.name = field.name.replace('[0]', nameIdx)
    })
}
1212972
public function setFieldsFromArray(Array $fields) {
    foreach ($fields as $field => $value) {
      $this->set($field, $value);
    }
    return $this;
  }
586201
public function getDefaultFlexformValues(array &$fieldArray)
    {
        foreach ($GLOBALS['TCA']['tt_content']['columns']['pi_flexform']['config']['ds'] as $key => $dataStructure) {
            $types = GeneralUtility::trimExplode(',', $key);
            if (($types[0] === $fieldArray['list_type'] || $types[0] === '*') && ($types[1] === $fieldArray['CType'] || $types[1] === '*')) {
                $fieldArray['pi_flexform'] = $this->extractDefaultDataFromDataStructure($dataStructure);
            }
        }
    }
343010
public function updateCMSFields(FieldList $fields)
    {
        if (!Permission::check("VIEW_SECTIONS")) {
            return $fields;
        }

        $SectionGrid = GridFieldConfig_RelationEditor::create()
            ->removeComponentsByType('GridFieldAddNewButton')
            ->addComponent(new GridFieldAddNewMultiClass())
            ->addComponent(new GridFieldOrderableRows());

        $SectionGrid->getComponentByType('GridFieldAddExistingAutocompleter')
            ->setSearchFields(array('AdminTitle', 'MenuTitle'))
            ->setResultsFormat('$AdminTitle - $Type');

        $AvailableTypes = $this->AvailableSectionTypes();

        foreach ($AvailableTypes as $key => $value) {
            if($value['selectable_option'] && !$value['limit_reached']){
                $AvailableTypes[$key] = $value['type'];
            }
        }

        $SectionGrid->getComponentByType('GridFieldAddNewMultiClass')
            ->setClasses($AvailableTypes);

        // Limit total sections
        $LimitSectionTotal = Config::inst()->get($this->owner->ClassName, 'LimitSectionTotal');
        if (isset($LimitSectionTotal) && $this->owner->Sections()->Count() >= $LimitSectionTotal) {
            // remove the buttons if we don't want to allow more records to be added/created
            $SectionGrid->removeComponentsByType('GridFieldAddNewButton');
            $SectionGrid->removeComponentsByType('GridFieldAddExistingAutocompleter');
            $SectionGrid->removeComponentsByType('GridFieldAddNewMultiClass');
        }

        if (!Permission::check("LINK_SECTIONS")) {
            $SectionGrid->removeComponentsByType('GridFieldAddExistingAutocompleter');
        }

        if (!Permission::check("REORDER_SECTIONS")) {
            $SectionGrid->removeComponentsByType('GridFieldOrderableRows');
        }

        if (!Permission::check("UNLINK_SECTIONS")) {
            $SectionGrid->removeComponentsByType('GridFieldDeleteAction');
        }

        $fields->addFieldToTab(
            'Root.Section',
            GridField::create(
                'Sections',
                'Current Section(s)',
                $this->owner->Sections(),
                $SectionGrid
            )
        );

        $fields->addFieldToTab(
            'Root.Preview',
            UploadField::create(
                'PreviewImage',
                'Preview image'
            )->setFolderName('Preview')
        );

        return $fields;
    }