Get additional field list based on field definition in metadata 'fields'

@param  string     $fieldName
@param  array     $fieldParams
@param  array|null $definitionList

@return array
541338
public function getAdditionalFieldList($fieldName, array $fieldParams, array $definitionList)
    {
        if (empty($fieldParams['type']) || empty($definitionList)) {
            return;
        }

        $fieldType = $fieldParams['type'];
        $fieldDefinition = isset($definitionList[$fieldType]) ? $definitionList[$fieldType] : null;

        if (isset($fieldDefinition) && !empty($fieldDefinition['fields']) && is_array($fieldDefinition['fields'])) {

            $copiedParams = array_intersect_key($fieldParams, array_flip($this->copiedDefParams));

            $additionalFields = array();

            //add additional fields
            foreach ($fieldDefinition['fields'] as $subFieldName => $subFieldParams) {
                $namingType = isset($fieldDefinition['naming']) ? $fieldDefinition['naming'] : $this->defaultNaming;

                $subFieldNaming = Util::getNaming($fieldName, $subFieldName, $namingType);
                $additionalFields[$subFieldNaming] = array_merge($copiedParams, $subFieldParams);
            }

            return $additionalFields;
        }

    }
1242909
protected function getFieldGetter(\ReflectionClass $reflectionClass, $fieldName)
    {
        foreach (array('get', 'is', 'has') as $prefix) {
            $getter = $prefix.ucfirst($fieldName);
            $reflectionMethod = $reflectionClass->getMethod($getter);

            if ($reflectionMethod && $reflectionMethod->isPublic()) {
                return $reflectionMethod;
            }
        }

        throw new EntityListException("The field $fieldName does not exist or is not accessible.");
    }
28253
public ArrayList getFields(String fieldNames) throws NoSuchFieldException
    {
        ArrayList          result    = new ArrayList();
        FieldDescriptorDef fieldDef;
        String             name;

        for (CommaListIterator it = new CommaListIterator(fieldNames); it.hasNext();)
        {
            name = it.getNext();
            fieldDef = getField(name);
            if (fieldDef == null)
            {
                throw new NoSuchFieldException(name);
            }
            result.add(fieldDef);
        }
        return result;
    }
894089
public function addListField(
        FieldMetadataInterface $itemMetadata,
        string $propertyName,
        string $dbFieldName = null
    ) {
        return $this->addField(new ListField($itemMetadata, $propertyName, $dbFieldName));
    }
835107
public function getWhereParametersFor($fieldName)
    {
        return array_intersect_key(
            $this->getWhereParameters(),
            array_flip(preg_grep('/^' . $fieldName . '_\d+$/', array_keys($this->getWhereParameters())))
        );
    }
1288011
public function updateCMSFields(FieldList $fields)
    {
        if (!$this->supportsElemental()) {
            return;
        }

        // add an empty holder for content as some module explicitly use insert
        // after content.
        $fields->replaceField('Content', new LiteralField('Content', ''));
        $elementalAreaRelations = $this->owner->getElementalRelations();

        foreach ($elementalAreaRelations as $eaRelationship) {
            $key = $eaRelationship . 'ID';

            // remove the scaffold dropdown
            $fields->removeByName($key);

            // remove the field, but don't add anything.
            if (!$this->owner->isInDb()) {
                continue;
            }

            // Example: $eaRelationship = 'ElementalArea';
            $area = $this->owner->$eaRelationship();

            $editor = ElementalAreaField::create($eaRelationship, $area, $this->getElementalTypes());

            if ($this->owner instanceof SiteTree && $fields->findOrMakeTab('Root.Main')->fieldByName('Metadata')) {
                $fields->addFieldToTab('Root.Main', $editor, 'Metadata');
            } else {
                $fields->addFieldToTab('Root.Main', $editor);
            }
        }

        return $fields;
    }
262948
private function findFieldsInTableSpec($fieldName, $spec)
    {
        $fields = [];
        if(is_array($spec) && !empty($spec))
        {
            if(array_key_exists($fieldName, $spec))
            {
                $fields = $spec[$fieldName];
            }

            if(isset($spec['joins']))
            {
                foreach($spec['joins'] as $join)
                {
                    $fields = array_merge($fields, $this->findFieldsInTableSpec($fieldName, $join));
                }
            }
        }
        return $fields;
    }
738298
public function getFieldByPropertyName(string $propertyName): ?FieldMetadataInterface
    {
        foreach ($this->fieldsMetadata as $fieldMetadata) {
            if ($propertyName === $fieldMetadata->getPropertyName()) {
                return $fieldMetadata;
            }
        }

        return null;
    }
312174
public function getByField($fieldName, $keys)
    {
        $keys = (array)$keys;
        if (empty($keys)) {
            return [];
        }
        $table = $this->entity->getTable();
        if (!empty($this->with)) {
            if (strpos($fieldName, '.') === false) {
                $fieldName = $this->getTableAlias($table) . '.' . $fieldName;
            }
        }
        $this->manager->commit();

        return $this->process(
            $this->getSelectQuery($table, $this->getFields($table), $fieldName, $keys)
                 ->query($this->parameters)
        );
    }
1316545
protected function getFieldName($fieldName)
	{
		if ($fieldName)
		{
			return $fieldName;
		}
		else
		{
			self::$count = self::$count + 1;

			return self::$generated_fieldname . self::$count;
		}
	}
158280
public function getColumnNames(array $fieldNames = null)
    {
        if ($fieldNames === null) {
            return array_keys($this->fieldNames);
        } else {
            $columnNames = array();
            foreach ($fieldNames as $fieldName) {
                $columnNames[] = $this->getColumnName($fieldName);
            }
            return $columnNames;
        }
    }
281159
public function & GetField ($fieldName = '') {
		$result = NULL;
		if (isset($this->fields[$fieldName]))
			$result = & $this->fields[$fieldName];
		return $result;
	}
700657
public function getErrors($fieldName=null)
    {
        if ($fieldName === null) {
            return $this->errors;
        }

        if (isset($this->errors[$fieldName])) {
            return $this->errors[$fieldName];
        }

        return [];
    }
336073
public function getMetaTags($tagName, array $params = array())
    {
        if (!isset($params[0])) {
            throw new InvalidArgumentException(
                '$params[0]',
                'Field type handlers require at least a field identifier.'
            );
        }

        $fieldIdentifiers = is_array($params[0]) ? $params[0] : array($params[0]);
        $fieldValue = $this->getFallbackValue($tagName, $params);

        foreach ($fieldIdentifiers as $fieldIdentifier) {
            $field = $this->validateField($fieldIdentifier);

            try {
                $fieldValue = $this->getFieldValue($field, $tagName, $params);
                break;
            } catch (FieldEmptyException $e) {
                // do nothing
            }
        }

        return array(
            new Item(
                $tagName,
                $fieldValue
            ),
        );
    }
894486
public function getFieldMapping($fieldName)
    {
        if (!$this->hasField($fieldName)) {
            throw MappingException::fieldNotFound($this->name, $fieldName);
        }

        return $this->mappings[$fieldName];
    }
804648
protected function generateFieldSql( $fieldName, ezcDbSchemaField $fieldDefinition )
    {
        $sqlDefinition = "'$fieldName' ";
        $defList = array();

        $type = $this->convertFromGenericType( $fieldDefinition );
        $defList[] = $type;

        if ( $fieldDefinition->notNull )
        {
            $defList[] = 'NOT NULL';
        }

        if ( $fieldDefinition->autoIncrement )
        {
            $defList[] = "PRIMARY KEY AUTOINCREMENT";
            $this->context['skip_primary'] = true;
        }
        
        if ( !is_null( $fieldDefinition->default ) && !$fieldDefinition->autoIncrement )
        {
            $default = $this->generateDefault( $fieldDefinition->type, $fieldDefinition->default );
            $defList[] = "DEFAULT $default";
        }

        $sqlDefinition .= join( ' ', $defList );

        return $sqlDefinition;
    }
830926
public function generateCMSFields(FieldList $fields)
    {
        /** @var News $owner */
        $owner = $this->owner;
        /** @var SiteConfig $siteConfig */
        $siteConfig = SiteConfig::current_site_config();
        $this->type_array = array(
            'news' => _t('News.NEWSITEMTYPE', 'Newsitem'),
        );
        /** Setup all fields according. Their visibility is based on the origin, which can be read from the functionname and comments. */
        $this->defaultFields();
        $this->multipleNewsHolderPages();
        $this->siteConfigFields($owner, $siteConfig);
        $this->existingItem($owner, $siteConfig);
        $this->displayLogic();
        $this->createHelptab();
        if (count($this->type_array) > 1) {
            $this->field_list['Root.Main'][3] = OptionsetField::create('Type', $owner->fieldLabel('Type'), $this->type_array, $owner->Type);
        }
        $this->setupFields($owner, $fields);
    }