feat: Add logging for Räumungsklage creation to source entity stream
This commit is contained in:
@@ -5,6 +5,8 @@ namespace Espo\Custom\Services;
|
|||||||
use Espo\Core\Exceptions\Forbidden;
|
use Espo\Core\Exceptions\Forbidden;
|
||||||
use Espo\Core\Exceptions\NotFound;
|
use Espo\Core\Exceptions\NotFound;
|
||||||
use Espo\Core\Exceptions\BadRequest;
|
use Espo\Core\Exceptions\BadRequest;
|
||||||
|
use Espo\Tools\Stream\Service as StreamService;
|
||||||
|
use Espo\Entities\Note;
|
||||||
|
|
||||||
class CVmhRumungsklage extends \Espo\Services\Record
|
class CVmhRumungsklage extends \Espo\Services\Record
|
||||||
{
|
{
|
||||||
@@ -48,7 +50,10 @@ class CVmhRumungsklage extends \Espo\Services\Record
|
|||||||
// 5. Create Räumungsklage from collected entities
|
// 5. Create Räumungsklage from collected entities
|
||||||
$result = $this->createFromCollectedEntities($alleMietverhaeltnisse, $alleKuendigungen);
|
$result = $this->createFromCollectedEntities($alleMietverhaeltnisse, $alleKuendigungen);
|
||||||
|
|
||||||
// 6. Commit transaction
|
// 6. Log to stream
|
||||||
|
$this->logToStream($sourceEntity, $sourceEntityType, $result['id']);
|
||||||
|
|
||||||
|
// 7. Commit transaction
|
||||||
$this->entityManager->getTransactionManager()->commit();
|
$this->entityManager->getTransactionManager()->commit();
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
@@ -358,4 +363,34 @@ class CVmhRumungsklage extends \Espo\Services\Record
|
|||||||
'name' => $raeumungsklage->get('name')
|
'name' => $raeumungsklage->get('name')
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log Räumungsklage creation to source entity stream
|
||||||
|
*
|
||||||
|
* @param object $sourceEntity Source entity (Mietverhältnis or Kündigung)
|
||||||
|
* @param string $sourceEntityType Entity type
|
||||||
|
* @param string $raeumungsklagenId Created Räumungsklage ID
|
||||||
|
*/
|
||||||
|
private function logToStream($sourceEntity, string $sourceEntityType, string $raeumungsklagenId): void
|
||||||
|
{
|
||||||
|
// Create stream service
|
||||||
|
$streamService = $this->injectableFactory->create(StreamService::class);
|
||||||
|
|
||||||
|
// Create Note entity manually for custom message
|
||||||
|
$note = $this->entityManager->getEntity('Note');
|
||||||
|
$note->set([
|
||||||
|
'type' => Note::TYPE_CREATE_RELATED,
|
||||||
|
'parentType' => $sourceEntityType,
|
||||||
|
'parentId' => $sourceEntity->getId(),
|
||||||
|
'relatedType' => 'CVmhRumungsklage',
|
||||||
|
'relatedId' => $raeumungsklagenId,
|
||||||
|
'data' => [
|
||||||
|
'action' => 'initiateEviction',
|
||||||
|
'actionLabel' => 'Räumungsklage einleiten'
|
||||||
|
]
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->entityManager->saveEntity($note);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -361,8 +361,8 @@ return [
|
|||||||
0 => 'youtube.com',
|
0 => 'youtube.com',
|
||||||
1 => 'google.com'
|
1 => 'google.com'
|
||||||
],
|
],
|
||||||
'cacheTimestamp' => 1769362554,
|
'cacheTimestamp' => 1769362656,
|
||||||
'microtime' => 1769362554.500343,
|
'microtime' => 1769362656.728453,
|
||||||
'siteUrl' => 'https://crm.bitbylaw.com',
|
'siteUrl' => 'https://crm.bitbylaw.com',
|
||||||
'fullTextSearchMinLength' => 4,
|
'fullTextSearchMinLength' => 4,
|
||||||
'appTimestamp' => 1768843902,
|
'appTimestamp' => 1768843902,
|
||||||
|
|||||||
Reference in New Issue
Block a user