private function getFieldsForPrimaryKeyMapping(array $fields): array
    {
        $primaryKeys = array_filter($fields, function (Field $field) {
            return $field->is(PrimaryKey::class);
        });

        $references = array_filter($fields, function (Field $field) {
            return $field instanceof ManyToOneAssociationField;
        });

        foreach ($primaryKeys as $primaryKey) {
            if (!$primaryKey instanceof FkField) {
                continue;
            }

            $association = $this->getAssociationByStorageName($primaryKey->getStorageName(), $references);
            if ($association) {
                $primaryKeys[] = $association;
            }
        }

        usort($primaryKeys, function (Field $a, Field $b) {
            return $b->getExtractPriority() <=> $a->getExtractPriority();
        });

        return $primaryKeys;
    }
private function getFieldsForPrimaryKeyMapping(array $fields): array
    {
        $primaryKeys = array_filter($fields, function (Field $field) {
            return $field->is(PrimaryKey::class);
        });

        $references = array_filter($fields, function (Field $field) {
            return $field instanceof ManyToOneAssociationField;
        });

        foreach ($primaryKeys as $primaryKey) {
            if (!$primaryKey instanceof FkField) {
                continue;
            }

            $association = $this->getAssociationByStorageName($primaryKey->getStorageName(), $references);
            if ($association) {
                $primaryKeys[] = $association;
            }
        }

        usort($primaryKeys, function (Field $a, Field $b) {
            return $b->getExtractPriority() <=> $a->getExtractPriority();
        });

        return $primaryKeys;
    }
private function getFieldsForPrimaryKeyMapping ( array $ fields ) : array { $ primaryKeys = array_filter ( $ fields , function ( Field $ field ) { return $ field -> is ( PrimaryKey :: class ) ; } ) ; $ references = array_filter ( $ fields , function ( Field $ field ) { return $ field instanceof ManyToOneAssociationField ; } ) ; foreach ( $ primaryKeys as $ primaryKey ) { if ( ! $ primaryKey instanceof FkField ) { continue ; } $ association = $ this -> getAssociationByStorageName ( $ primaryKey -> getStorageName ( ) , $ references ) ; if ( $ association ) { $ primaryKeys [ ] = $ association ; } } usort ( $ primaryKeys , function ( Field $ a , Field $ b ) { return $ b -> getExtractPriority ( ) <=> $ a -> getExtractPriority ( ) ; } ) ; return $ primaryKeys ; }
Returns all fields which are relevant to extract and map the primary key data of an entity definition data array.
In case a primary key consist of Foreign Key fields, the corresponding association for these foreign keys must be
returned in order to guarantee the creation of these sub entities and to extract the corresponding foreign key value
from the nested data array

Example: ProductCategoryDefinition
Primary key:   product_id, category_id

Both fields are defined as foreign key field.
It is now possible to create both related entities (product and category), providing a nested data array:
[
'product' => ['id' => '..', 'name' => '..'],
'category' => ['id' => '..', 'name' => '..']
]

To extract the primary key data of the ProductCategoryDefinition it is required to extract first the product
and category association and their foreign key fields.

@param Field[] $fields

@return Field[]
Returns all fields which are relevant to extract and map the primary key data of an entity definition data array . In case a primary key consist of Foreign Key fields the corresponding association for these foreign keys must be returned in order to guarantee the creation of these sub entities and to extract the corresponding foreign key value from the nested data array