Return normalized field array

@param object $model
@param array $settings
@return array
329824
protected function _normalizeFields($model, $settings = array()) {
		if (empty($settings)) {
			$settings = $this->settings[$model->alias];
		}
		$result = array();
		foreach ($settings as $flag => $date) {
			if (is_numeric($flag)) {
				$flag = $date;
				$date = false;
			}
			$result[$flag] = $date;
		}
		return $result;
	}
256709
public function getDetailAttributes($model, $fields)
    {
        if (!$model instanceof ActiveRecord) {
            return $model->attributes();
        }
        /** @var ActiveRecord $model */
        $formats = $model->attributeFormats();
        $keys    = self::getModelKeys($model);
        list($behaviorAttributes, $blameableAttributes) = self::getModelBehaviorAttributes($model);
        $attributes = $model->attributes();
        $versionAttribute = $model->optimisticLock();
        $result = [];
        foreach ($fields as $key => $field) {
            if (is_array($field)) {
                $result[$key] = $field;
                continue;
            } elseif (!is_string($field) && is_callable($field)) {
                $result[$key] = call_user_func($field, $model);
                continue;
            }

            if (in_array($field, $attributes)) {
                if (in_array($field, $keys) || in_array($field, $blameableAttributes) || $field === $versionAttribute) {
                    continue;
                }
                $result[$field] = [
                    'attribute' => $field,
                    'format' => $formats[$field],
                ];
                continue;
            }

            $relation = $model->getRelation($field);
            if (!$relation->multiple) {
                // validate foreign keys only for hasOne relations
                foreach ($relation->link as $left => $right) {
                    if (in_array($left, $blameableAttributes)) {
                        continue;
                    }
                }
            }

            if (!Yii::$app->user->can($relation->modelClass . '.read')) {
                continue;
            }
            $result[$field] = [
                'attribute' => $field,
                'format'    => 'crudLink',
                'visible'   => true,
                'label'     => $model instanceof ActiveRecord ? $model->getRelationLabel($relation, $field) : null,
            ];
        }
        return $result;
    }
1254891
def get_fields(model, fields, meta=None):
    
    model = get_model(model)
    if fields is not None:
        f = fields
    elif meta and hasattr(model, meta):
        m = getattr(model, meta)
        if hasattr(m, 'fields'):
            f = m.fields
        else:
            f = model._fields_list
    else:
        f = model._fields_list
        
    fields_list = []
    for x in f:
        field = {}
        if isinstance(x, str):  #so x is field_name
            field['name'] = x
        elif isinstance(x, tuple):
            field['name'] = x[0]
            field['field'] = x[1]
        elif isinstance(x, dict):
            field = x.copy()
        else:
            raise UliwebError('Field definition {!r} is not right, it should be just like (field_name, form_field_obj)'.format(x))
        
        if 'prop' not in field:
            if hasattr(model, field['name']):
                field['prop'] = getattr(model, field['name'])
            else:
                field['prop'] = None
        
        fields_list.append((field['name'], field))
    return fields_list
456219
public function getList(Model $model) {
        return $model->find('list', array(
            'order' => array($model->alias . '.' . $model->displayField => 'ASC'),
            'cache' => $model->alias . '::getList',
            'cacheExpires' => $this->getExpiration($model)
        ));
    }
1363700
public function settings(array $settings = null)
    {
        if ($settings) {
            $this->_settings = array_merge($this->_settings, $settings);
        }
        return $this->_settings;
    }
1109053
public function bulkSerialise($model)
    {
        $class = get_class($model);
        if (!$model instanceof Model) {
            throw new InvalidOperationException($class);
        }
        // dig up metadata
        if (!isset(self::$metadataCache[$class])) {
            self::$metadataCache[$class] = $model->metadata();
        }
        $meta = self::$metadataCache[$class];
        $keys = array_keys($meta);
        // dig up getter list - we only care about the mutators that end up in metadata
        if (!isset(self::$mutatorCache[$class])) {
            $getterz = [];
            $datez = $model->getDates();
            $castz = $model->retrieveCasts();
            foreach ($keys as $key) {
                if ($model->hasGetMutator($key) || in_array($key, $datez) || array_key_exists($key, $castz)) {
                    $getterz[] = $key;
                }
            }
            self::$mutatorCache[$class] = $getterz;
        }
        $getterz = self::$mutatorCache[$class];
        $modelAttrib = $model->getAttributes();
        $result = array_intersect_key($modelAttrib, $meta);
        foreach ($keys as $key) {
            if (!isset($result[$key])) {
                $result[$key] = null;
            }
        }
        foreach ($getterz as $getter) {
            $result[$getter] = $model->$getter;
        }

        return $result;
    }
993047
protected function initObject(array $settings): array
    {
        $settings += static::$settings ?? [];
        foreach ($settings as $name => &$value) {
            $propertyName = null;
            if (property_exists($this, $name)) {
                $propertyName = $name;
                unset($settings[$name]);
            }

            if ($propertyName !== null
                && property_exists($this, NameConverter::snakeCaseToLowerCamelCase($name))) {
                $propertyName = NameConverter::snakeCaseToLowerCamelCase($name);
                unset($settings[$name]);
            }

            if (!$propertyName) {
                continue;
            }

            $methodName = 'set' . ucfirst($propertyName);
            if (is_callable([$this, $methodName])) {
                $this->{$methodName}($value);
                continue;
            }

            if (array_key_exists($propertyName, get_object_vars($this))) {
                $this->{$propertyName} = $value;
            }
        }

        unset($value);

        return $settings;
    }
1352193
protected function getBlameableFields(Model $model)
    {
        if (isset($this->fields)) {
            return $this->fields;
        }

        $this->fields = self::findBlameableFields($model);

        return $this->fields;
    }
989669
public function array_filter($inputArray, $model)
    {
        $outputArray = array();
        foreach ($inputArray as $key => $value) {
            // Null and empty string are skipped
            if (is_null($value) || $value === '') {
                continue;
            }
            // Maybe do a check on multiOptions for checkboxes etc. to disable some 0 values $model->get($key, 'multiOptions');
            if ($value == '0' && $options = $model->get($key, 'multiOptions')) {
                if (count($options) == 2) {
                    // Probably a checkbox (multi flexi in limesurvey)
                    continue;
                }
            }
            $outputArray[$key] = $value;
        }
        return $outputArray;
    }
1206929
public function importFields($model, $fields = null)
    {
        $this->model = $model;
        $this->grid = $this->owner;

        if ($fields === false) {
            return;
        }

        $fields_supplied = (boolean)$fields;

        if (!$fields) {
            if ($model->only_fields) {
                $fields = $model->only_fields;
            } else {
                $fields = [];
                // get all field-elements
                foreach ($model->elements as $field => $f_object) {
                    if ($f_object instanceof \atk4\data\Field
                        && $f_object->isVisible()
                        && !$f_object->isHidden()
                    ) {
                        $fields[] = $field;
                    }
                }
            }
        }

        if (!is_array($fields)) {
            $fields = [$fields];
        }

        // import fields one by one
        foreach ($fields as $field) {
            $this->importField($field);
        }
        if ($fields_supplied) {
            $model->onlyFields($fields);
        }

        return $this;
    }
308965
private function normalizeFields($_fields)
    {
        $fields = [];
        foreach ($_fields as $key => $value) {
            if (is_array($value)) {
                $fields[$key] = $value;
            } else {
                $fields[$value] = [];
            }
        }
        return $fields;
    }
478278
private function applyOrders(array $settings): array
    {
        $orders = [];
        // Obtain a list of columns
        foreach ($settings as $column => $order) {
            $column = Proxy\Db::quoteIdentifier($column);
            $orders[] = $column . ' ' . $order;
        }
        return $orders;
    }
429517
protected function parseAliases(Model $settings)
    {
        $aliasables = ['manifestPath', 'assetsBasePath', 'assetUrlPrefix'];

        foreach ($aliasables as $aliasable) {
            $settings->{$aliasable} = Yii::getAlias($settings->{$aliasable});
        }

        return $settings;
    }
635111
public function getMainField($model)
    {
        // describe the model
        $desc = $this->desc($model);

        // search by fields for primary key
        foreach (array_keys($desc[$model]) as $field) {
            return $field;
        }
    }
1131356
protected function getAllowedAclFields(Model $model, $scenario)
    {
        $privilege = ['set', 'set_on_' . $scenario];
        $acl = app(AclContract::class);
        $modelClass = get_class($model);
        $cacheKey = sha1(json_encode($privilege) . $acl->getContextId() . $modelClass);
        if (!isset($this->fieldAclCache[$cacheKey])) {
            $this->fieldAclCache[$cacheKey] = [];
            $this->fieldAclCache[$cacheKey][] = 'meta';
            foreach ($model->getFields() as $fieldName) {
                if ($acl->isAllowedField($modelClass, $fieldName, $privilege)) {
                    $this->fieldAclCache[$cacheKey][] = $fieldName;
                }
            }
            foreach ($model->metaFields() as $fieldName) {
                $metaFieldName = 'meta.' . $fieldName;
                if ($acl->isAllowedField($modelClass, $metaFieldName, $privilege)) {
                    $this->fieldAclCache[$cacheKey][] = $metaFieldName;
                }
            }
        }
        return $this->fieldAclCache[$cacheKey];
    }
7292
private function getMutableAttributes($model)
    {
        $attrs = get_object_vars($model);
        unset($attrs[$this->key]);
        
        // remove reference attributes, if any
        if ($model instanceof ManagedModelInterface) {
            foreach (array_keys($model->getReferences()) as $ref) {
                unset($attrs[$ref]);
            }
        }
        
        return $attrs;
    }
680473
public static function getRoutesFromSettings(array $settings): array{
        $routes = [];
        foreach ($settings['routing'] as $method => $urls) {
            if (!isset($routes[$method])) {
                $routes[$method] = [];
            }
            foreach ($urls as $url) {
                array_push($routes[$method], (array)$url);
            }
        }
        return $routes;
    }