Skip to content
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/Listener/RelatedModelsListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@ public function publishRelatedModels(?string $action = null, ?EntityInterface $e
*/
protected function _findOptions(Association $association): array
{
if ($association instanceof Association\BelongsToMany) {
Comment thread
ravage84 marked this conversation as resolved.
Outdated
return [
'keyField' => $association->getPrimaryKey(),
];
}

return [
'keyField' => $association->getBindingKey(),
];

@ravage84 ravage84 Jan 18, 2024

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively, the code could look like this:

Suggested change
if ($association instanceof Association\BelongsToMany) {
return [
'keyField' => $association->getPrimaryKey(),
];
}
return [
'keyField' => $association->getBindingKey(),
];
$keyField = $association->getBindingKey();
if ($association instanceof Association\BelongsToMany) {
$keyField = $association->getPrimaryKey();
}
return [
'keyField' =>$keyField,
];

Expand Down