Refactor AdvowareAkte ↔ CDokumente relationship from junction table to direct n:1 relationship
- Removed CAdvowareAktenCDokumente junction table and associated service. - Updated CDokumente entity to include foreign key cAdvowareAktenId and related fields. - Changed relationship in CDokumente from hasMany to belongsTo. - Updated CAdvowareAkten to reflect new direct relationship. - Implemented CDokumente service with duplicateDocument method for document duplication. - Refactored hooks to support new relationship and document propagation. - Removed obsolete API routes related to the junction table. - Added i18n translations for new fields and updated tooltips. - Document flow and auto-linking logic enhanced for better integration with Advoware. - Validation checks passed, and no data migration needed.
This commit is contained in:
@@ -1,47 +0,0 @@
|
||||
<?php
|
||||
namespace Espo\Custom\Hooks\CAdvowareAkten;
|
||||
|
||||
use Espo\ORM\Entity;
|
||||
use Espo\Core\Hook\Hook\AfterRelate;
|
||||
|
||||
/**
|
||||
* Hook: Setzt Dokument-Sync-Status auf "new" beim Verknüpfen und
|
||||
* globalen syncStatus auf "unclean"
|
||||
*/
|
||||
class DokumenteSyncStatus implements AfterRelate
|
||||
{
|
||||
public function __construct(
|
||||
private \Espo\ORM\EntityManager $entityManager
|
||||
) {}
|
||||
|
||||
public function afterRelate(
|
||||
Entity $entity,
|
||||
string $relationName,
|
||||
Entity $foreignEntity,
|
||||
array $columnData,
|
||||
\Espo\ORM\Repository\Option\RelateOptions $options
|
||||
): void {
|
||||
// Nur für dokumentes-Beziehung
|
||||
if ($relationName !== 'dokumentes') {
|
||||
return;
|
||||
}
|
||||
|
||||
// Setze Sync-Status des Dokuments in der Junction-Tabelle auf "new"
|
||||
$repository = $this->entityManager->getRDBRepository('CAdvowareAkten');
|
||||
|
||||
try {
|
||||
$repository->getRelation($entity, 'dokumentes')->updateColumns(
|
||||
$foreignEntity,
|
||||
['syncstatus' => 'new']
|
||||
);
|
||||
|
||||
// Setze globalen syncStatus auf "unclean"
|
||||
$entity->set('syncStatus', 'unclean');
|
||||
$this->entityManager->saveEntity($entity, ['silent' => true, 'skipHooks' => true]);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
// Fehler loggen, aber nicht werfen (um Verknüpfung nicht zu blockieren)
|
||||
$GLOBALS['log']->error('CAdvowareAkten DokumenteSyncStatus Hook Error: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user