Get field layout fields definition.

@param FieldInterface[] $fields

@return array
556301
private function getFieldLayoutFieldsDefinition(array $fields): array
    {
        $fieldDefinitions = [];

        foreach ($fields as $field) {
            $fieldDefinitions[$field->handle] = $field->required;
        }

        return $fieldDefinitions;
    }
771491
public function getAllCustomFields(array $fields = [])
    {
        if (!$models = Modules::findFirstByName($this->getSource())) {
            return;
        }

        $conditions = [];
        $fieldsIn = null;

        if (!empty($fields)) {
            $fieldsIn = " and name in ('" . implode("','", $fields) . ')';
        }

        $conditions = 'modules_id = ? ' . $fieldsIn;

        $bind = [$this->getId(), $models->getId()];

        $customFieldsValueTable = $this->getSource() . '_custom_fields';

        $result = $this->getReadConnection()->prepare("SELECT l.{$this->getSource()}_id,
                                               c.id as field_id,
                                               c.name,
                                               l.value ,
                                               c.users_id,
                                               l.created_at,
                                               l.updated_at
                                        FROM {$customFieldsValueTable} l,
                                             custom_fields c
                                        WHERE c.id = l.custom_fields_id
                                          AND l.leads_id = ?
                                          AND c.modules_id = ? ");

        $result->execute($bind);

        // $listOfCustomFields = $result->fetchAll();
        $listOfCustomFields = [];

        while ($row = $result->fetch(\PDO::FETCH_OBJ)) {
            $listOfCustomFields[$row->name] = $row->value;
        }

        return $listOfCustomFields;
    }
238893
protected function getFormRules(array $fields)
    {
        $rules = [];

        foreach ($fields as $field) {
            /** @var FieldTypeInterface $field */
            $rules[$field->getName()] = $field->getOption('rules');
        }

        return $rules;
    }
20990
public function fields(array $fields)
    {
        $newFields = array();
        $this->fields = '';
        $this->fieldsArguments = array();

        foreach ($fields as $field) {
            if (is_scalar($field)) {
                $newFields[] = '?f:alias:.?f';
                $this->fieldsArguments[] = $field;
            } else {
                if (!isset($field[0]) or !isset($field[1]) or !is_array($field[1])) {
                    throw new \BadMethodCallException('Must be exist 0 and 1 index in array and second one must be an array');
                }
                $newFields[] = $field[0];
                $this->fieldsArguments = array_merge($this->fieldsArguments, $field[1]);
            }
        }

        $this->fields = implode(', ', $newFields);

        return $this;
    }
319239
public function prepareBinding(array $fields) {
        $output = [];
        foreach ($fields as $current) {
            $output[$current] = ":" . $current;
        }
        return $output;
    }
293421
public function prepareSort(array $fields) : array
    {
        $sortFields = [];

        foreach ($fields as $key => $value) {
            if (is_array($value)) {
                $sortFields[$this->prepareFieldName($key)] = $value;
            } else {
                $sortFields[$this->prepareFieldName($key)] = $this->getSortDirection($value);
            }
        }

        return $sortFields;
    }
145104
public function getFormFieldValueOptions(FieldInterface $field)
    {
        $fieldOptions = $this->getFieldOptions($field);

        $formFieldOptions = [];
        if (isset($fieldOptions['minLength'])) {
            $formFieldOptions['constraints'][] = new Length(['min' => $fieldOptions['minLength']]);
        }
        if (isset($fieldOptions['maxLength'])) {
            $formFieldOptions['constraints'][] = new Length(['max' => $fieldOptions['maxLength']]);
        }

        return $formFieldOptions;
    }
1079380
public function getTitleFields(array $fields)
    {
        $fields = array_map(function ($field) {
            if (str_contains($field, '.')) {
                return object_get($this, $field); // this acts as a delimiter, which we can replace with /
            } else {
                return $this->{$field};
            }
        }, $fields);

        return $fields;
    }
358339
public function getIndexBodyCells(array $fields = null)
    {
        $rows = '';
        $stub = $this->getStubContent('index.body.cell.blade', $this->template);
        foreach ($this->getFieldsToDisplay($fields) as $field) {
            if ($field->isOnIndexView) {
                $rows .= $this->getIndexBodyCell($stub, $field) . PHP_EOL;
            }
        }

        return $rows;
    }
1202523
public function getFieldLayoutDefinition(FieldLayout $fieldLayout): array
    {
        if ($fieldLayout->getTabs()) {
            $tabDefinitions = [];

            foreach ($fieldLayout->getTabs() as $tab) {
                $tabDefinitions[$tab->name] = $this->getFieldLayoutFieldsDefinition($tab->getFields());
            }

            return [
                'type' => $fieldLayout->type,
                'tabs' => $tabDefinitions
            ];
        }

        return [
            'type' => $fieldLayout->type,
            'fields' => $this->getFieldLayoutFieldsDefinition($fieldLayout->getFields()),
        ];
    }
929978
public function getFormFieldValueOptions(FieldInterface $field)
    {
        $options = $field->getOptions();

        $message = '';
        if (isset($options['message'])) {
            $message = $options['message'];
        }

        return ['message' => $message];
    }
657561
public function parseField($fields){
        if(empty($fields)) {
            $fields    = array();
        }
        if(is_string($fields)) {
            $_fields    = explode(',',$fields);
            $fields     = array();
            foreach ($_fields as $f)
                $fields[$f] = true;
        }elseif(is_array($fields)) {
            $_fields    = $fields;
            $fields     = array();
            foreach ($_fields as $f=>$v) {
                if(is_numeric($f))
                    $fields[$v] = true;
                else
                    $fields[$f] = $v ? true : false;
            }
        }
        return $fields;
    }
423163
protected function getMergedFields(array $fields)
    {
        if (0 === \count($fields)) {
            // If we didn't specify the fields (filtered), we get all variation fields possible values
            $fields = $this->getVariationFields();
        } else {
            foreach ($fields as $field) {
                if (!\in_array($field, $this->getVariationFields(), true)) {
                    throw new \RuntimeException("The field '".$field."' is not among the variation fields");
                }
            }
        }

        return $fields;
    }
1053641
public function layout(): array
    {
        if ($this->layout && count($this->layout)) {
            return $this->layout;
        }

        return array_keys($this->fields);
    }
251603
public function generateFields(array $fields): array
    {
        $traitFqns = [];
        foreach ($fields as list($fieldFqn, $fieldType)) {
            try {
                $traitFqns[] = $this->fieldGenerator->generateField($fieldFqn, $fieldType);
            } catch (\Exception $e) {
                throw new \RuntimeException(
                    'Failed building field with $fieldFqn: ' . $fieldFqn . ' and $fieldType ' . $fieldType,
                    $e->getCode(),
                    $e
                );
            }
        }

        return $traitFqns;
    }
628636
public function getFieldType($field)
    {
        $definition = $this->getFieldDefinition($field);
        if ($definition && isset($definition['type'])) {
            return $definition['type'];
        }
    }
163762
protected function getConstraintsFromfields(array $fields)
    {
        $constraints = [];

        foreach ($fields as $field) {
            if ($field->hasForeignConstraint()) {
                $constraints[] = $field->getForeignConstraint();
            }
        }

        return $constraints;
    }