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

Added function for updating taak with zaak #80

Merged
merged 7 commits into from
Oct 9, 2024
Merged
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
44 changes: 40 additions & 4 deletions src/Service/ZaakService.php
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,31 @@ public function getZaak(array $configuration, string $caseID)
}//end getZaak()


/**
* Updates the taak with the zaak url.
*
* @param ObjectEntity $zaak The zaak object.
* @param string $taakId The taak id.
*
* @return ObjectEntity The updated taak object.
*/
private function updateTaak(ObjectEntity $zaak, string $taakId): ObjectEntity
{
$this->logger->info("taakId found in body, trying to update taak with zaak url");

$zaak = $this->resourceService->getObject($zaak->getId()->toString(), 'common-gateway/xxllnc-zgw-bundle');
$taak = $this->resourceService->getObject($taakId, 'common-gateway/xxllnc-zgw-bundle');
$taak->setValue('zaak', $zaak->getValue('url'));
$this->entityManager->persist($taak);
$this->entityManager->flush();

$this->logger->info("Updated taak with zaak url");

return $taak;

}//end updateTaak()


/**
* Creates or updates a ZGW Zaak from a xxllnc case with the use of mapping.
*
Expand All @@ -481,13 +506,24 @@ public function zaakHandler(?array $data = [], ?array $configuration = [])
return null;
}

// To generalize stuff..
if (isset($data['body']['case_uuid']) === true) {
$data['case_uuid'] = $data['body']['case_uuid'];
}

if (isset($data['caseId']) === true) {
$this->getZaak($configuration, $data['caseId']);
return $data;
$zaak = $this->getZaak($configuration, $data['caseId']);
} else if (isset($data['case_uuid']) === true) {
$zaak = $this->getZaak($configuration, $data['case_uuid']);
}

if (isset($data['body']['case_uuid']) === true) {
$this->getZaak($configuration, $data['body']['case_uuid']);
// Check if we already synced the zaak.
if (isset($zaak) === true) {
// Check if we need to update the taak with the zaak url.
if (isset($data['taakId']) === true) {
$this->updateTaak($zaak, $data['taakId']);
}

return $data;
}

Expand Down