Enhance document synchronization hooks to handle linking and unlinking; update sync status for related entities; modify state file for cache and microtime values

This commit is contained in:
2026-03-27 09:52:28 +01:00
parent bd29d6e9b4
commit 2a18e62528
4 changed files with 107 additions and 20 deletions

View File

@@ -50,6 +50,12 @@ class PropagateDocuments implements AfterRelate, AfterUnrelate
$foreignEntity->set('cAktenId', $advowareAkten->getId());
$foreignEntity->set('syncStatus', 'new'); // Mark as new for Advoware sync
$this->entityManager->saveEntity($foreignEntity, ['silent' => true, 'skipHooks' => true]);
// Akte über neue Verlinkung informieren → syncStatus auf unclean
$akte = $this->entityManager->getEntityById('CAkten', $advowareAkten->getId());
if ($akte) {
$this->entityManager->saveEntity($akte, ['silent' => true]);
}
}
// Hole verbundene AIKnowledge
@@ -97,8 +103,15 @@ class PropagateDocuments implements AfterRelate, AfterUnrelate
// Remove direct belongsTo relationship from document
if ($advowareAkten && $foreignEntity->get('cAktenId') === $advowareAkten->getId()) {
$akteId = $advowareAkten->getId(); // Vor dem Löschen merken
$foreignEntity->set('cAktenId', null);
$this->entityManager->saveEntity($foreignEntity, ['silent' => true, 'skipHooks' => true]);
// Akte über Entlinkung informieren → syncStatus neu berechnen
$akte = $this->entityManager->getEntityById('CAkten', $akteId);
if ($akte) {
$this->entityManager->saveEntity($akte, ['silent' => true]);
}
}
// Hole verbundene AIKnowledge