Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set deleted collection only to the owner and be able to skip doctrine collections fields #43

Merged
merged 1 commit into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
CHANGELOG for 1.x
===================
## v1.13.1 - (2024-09-24)
### Fixed
- `HistoryDoctrineListener::handleHistory` set deleted collection only to the owner

### Added
- `HistorizableInterface::getHistoryDiffFieldsToSkip` be able to skip doctrine collections fields in `HistoryDoctrineListener::handleHistory`

## v1.13.0 - (2024-09-24)
### Added
- `EntityCleanupCommand` to delete cron, clean api calls or other entity easily through the bundle configuration **entity_cleanup_command_configs**
Expand Down
6 changes: 5 additions & 1 deletion src/EventListener/HistoryDoctrineListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ private function handleHistory(LifecycleEventArgs $args, string $code): void
$uow = $args->getObjectManager()->getUnitOfWork();
$entityClass = get_class($entity);
foreach ($uow->getScheduledCollectionUpdates() as $collection) {
if ($entityClass !== get_class($collection->getOwner())) {
if ($entityClass !== get_class($collection->getOwner()) || isset($diffFieldsToSkip[$collection->getMapping()['fieldName']])) {
continue;
}
// MDT the 'c_u' string is a shortcut index key meaning collection_update
Expand All @@ -102,6 +102,10 @@ private function handleHistory(LifecycleEventArgs $args, string $code): void
// MDT the preUpdate event is not triggered if the only modification of the event concerns the deletion of the collection
// cf. https://github.com/doctrine/orm/issues/9960
foreach ($uow->getScheduledCollectionDeletions() as $collection) {
if ($entityClass !== get_class($collection->getOwner()) || isset($diffFieldsToSkip[$collection->getMapping()['fieldName']])) {
continue;
}

$entityData[$collection->getMapping()['fieldName']] = 'label.empty';
}
$historyData[HistoryLogger::DIFF_PROPERTY] = $entityData;
Expand Down