$column =
$mapping['joinColumns'
][0
]['name'
];
$field =
$metaData->
getFieldForColumn($column);
if (isset($data[$field])) { $associationModel =
$this->
getManager()->
find($mapping['targetEntity'
],
$data[$field]);
// proxies need to be loaded, otherwise the validation will be failed.
if ($associationModel instanceof Proxy
) { $associationModel->
__load();
} $data[$mapping['fieldName'
]] =
$associationModel;
// remove the foreign key data.
if ($field !==
$mapping['fieldName'
]) { unset($data[$field]);
} } } elseif ($mapping['type'
] === ClassMetadataInfo::MANY_TO_MANY
) { /**
* @ORM\ManyToMany associations.
*
* The data of many to many association are contained in the corresponding field:
*
* @example
* model: Shopware\Models\Article\Article
* association: $categories (mapping table: s_articles_categories)
* joined: - s_articles.id <=> s_articles_categories.articleID
* - s_categories.id <=> s_articles_categories.categoryID
*
* passed data: 'categories' => array(
* array('id'=>1, ...),
* array('id'=>2, ...),
* array('id'=>3, ...)
* )
*/