KapostGridFieldDetailForm_ItemRequest::merge
Merges data and relations from another object of same class, without conflict resolution. Allows to specify which dataset takes priority in case its not empty. has_one-relations are just transferred with priority 'right'. has_many and many_many-relations are added regardless of priority.
Caution: has_many/many_many relations are moved rather than duplicated, meaning they are not connected to the merged object any longer. Caution: Just saves updated has_many/many_many relations to the database, doesn't write the updated object itself (just writes the object-properties). Caution: Does not delete the merged object. Caution: Does now overwrite Created date on the original object.
Signature
public function merge(DataObject
$leftObj,
DataObject
$rightObj,
[string
$priority = 'right',
[boolean
$includeRelations = true,
[boolean
$overwriteWithEmpty = false,
[boolean
$skipParent = true,
[string
$parentRelField = 'Parent']]]]] )
Parameters
$leftObj
— object- Left DataObject to merge into
$rightObj
— object- Right DataObject to merge from
$priority
— string- String left|right Determines who wins in case of a conflict (optional)
$includeRelations
— boolean- Boolean Merge any existing relations (optional)
$overwriteWithEmpty
— boolean- Boolean Overwrite existing left values with empty right values. Only applicable with $priority='right'. (optional)
$skipParent
— boolean- Skip the parent has_one relationship or not (defaults to true)
$parentRelField
— string- Name of the parent has_one relationship field (defaults to Parent)
Returns
- bool
- Returns boolean true on success false otherwise