save option keep relations

This commit is contained in:
Yuri Kuznetsov
2024-12-19 14:00:37 +02:00
parent b992ced5b4
commit 656ecba3de
3 changed files with 9 additions and 1 deletions
@@ -61,6 +61,11 @@ class SaveOption
* Keep dirty. Boolean.
*/
public const KEEP_DIRTY = BaseSaveOption::KEEP_DIRTY;
/**
* Keep an entity relations map. Boolean.
* @since 9.0.0
*/
public const KEEP_RELATIONS = BaseSaveOption::KEEP_RELATIONS;
/**
* Skip hooks. Boolean.
*/
@@ -34,4 +34,5 @@ class SaveOption
public const SKIP_ALL = 'skipAll';
public const KEEP_NEW = 'keepNew';
public const KEEP_DIRTY = 'keepDirty';
public const KEEP_RELATIONS = 'keepRelations';
}
@@ -182,7 +182,9 @@ class RDBRepository implements Repository
$entity->setAsNotBeingSaved();
}
$this->relationsMap?->get($entity)?->resetAll();
if (empty($options[SaveOption::KEEP_RELATIONS])) {
$this->relationsMap?->get($entity)?->resetAll();
}
}
/**