Update timestamp of the associated element.

For example the lastModified timestamp of a part is now updated, when the user changes a price information. This should represent more what a user expects under a last Modified field and should improve also sorting...
This commit is contained in:
Jan Böhmer 2020-05-20 23:36:44 +02:00
parent 2b21d4039a
commit dbf770f784
7 changed files with 68 additions and 4 deletions

View file

@ -172,7 +172,8 @@ class EventLoggerSubscriber implements EventSubscriber
$em = $args->getEntityManager();
$uow = $em->getUnitOfWork();
// If the we have added any ElementCreatedLogEntries added in postPersist, we flush them here.
if ($uow->hasPendingInsertions()) {
$uow->computeChangeSets();
if ($uow->hasPendingInsertions() || !empty($uow->getScheduledEntityUpdates())) {
$em->flush();
}
@ -266,6 +267,15 @@ class EventLoggerSubscriber implements EventSubscriber
{
$uow = $em->getUnitOfWork();
/* We have to call that here again, so the foreign entity timestamps, that were changed in updateTimestamp
get persisted */
$changeSet = $uow->getEntityChangeSet($entity);
//Skip log entry, if only the lastModified field has changed...
if (isset($changeSet['lastModified']) && count($changeSet)) {
return;
}
$log = new ElementEditedLogEntry($entity);
if ($this->save_changed_data) {
$this->saveChangeSet($entity, $log, $em);