From bcd9a5b5ff5c80bb19455fc1edb8f4d9e41fa4ba Mon Sep 17 00:00:00 2001 From: Barry Brands Date: Tue, 8 Oct 2024 15:32:09 +0200 Subject: [PATCH 1/6] Added function for updating taak with zaak --- src/Service/ZaakService.php | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/Service/ZaakService.php b/src/Service/ZaakService.php index 2e9fae8..61cca70 100644 --- a/src/Service/ZaakService.php +++ b/src/Service/ZaakService.php @@ -463,6 +463,29 @@ 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('url', $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. @@ -483,11 +506,16 @@ public function zaakHandler(?array $data = [], ?array $configuration = []) if (isset($data['caseId']) === true) { $this->getZaak($configuration, $data['caseId']); + return $data; } if (isset($data['body']['case_uuid']) === true) { - $this->getZaak($configuration, $data['body']['case_uuid']); + $zaak = $this->getZaak($configuration, $data['body']['case_uuid']); + + if (isset($data['taakId']) === true) { + $this->updateTaak($zaak, $data['taakId']); + } return $data; } From 7cfc81e6e06ea5ca97bfbe4e2c634efd36ceed5f Mon Sep 17 00:00:00 2001 From: GitHub Actions <> Date: Tue, 8 Oct 2024 13:32:40 +0000 Subject: [PATCH 2/6] Update src from PHP Codesniffer --- src/Service/ZaakService.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Service/ZaakService.php b/src/Service/ZaakService.php index 61cca70..083ad80 100644 --- a/src/Service/ZaakService.php +++ b/src/Service/ZaakService.php @@ -463,11 +463,12 @@ 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. + * @param ObjectEntity $zaak The zaak object. + * @param string $taakId The taak id. * * @return ObjectEntity The updated taak object. */ @@ -484,6 +485,7 @@ private function updateTaak(ObjectEntity $zaak, string $taakId): ObjectEntity $this->logger->info("Updated taak with zaak url"); return $taak; + }//end updateTaak() @@ -516,6 +518,7 @@ public function zaakHandler(?array $data = [], ?array $configuration = []) if (isset($data['taakId']) === true) { $this->updateTaak($zaak, $data['taakId']); } + return $data; } From b1b4aae009f04f42345797fdbb258591d71a6894 Mon Sep 17 00:00:00 2001 From: Barry Brands Date: Tue, 8 Oct 2024 15:36:22 +0200 Subject: [PATCH 3/6] Code improvement --- src/Service/ZaakService.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Service/ZaakService.php b/src/Service/ZaakService.php index 61cca70..eaabd0a 100644 --- a/src/Service/ZaakService.php +++ b/src/Service/ZaakService.php @@ -505,17 +505,20 @@ public function zaakHandler(?array $data = [], ?array $configuration = []) } if (isset($data['caseId']) === true) { - $this->getZaak($configuration, $data['caseId']); - - return $data; + $zaak = $this->getZaak($configuration, $data['caseId']); } if (isset($data['body']['case_uuid']) === true) { $zaak = $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; } From c68e8c04d8162bec98dadd533b6421c29805ce7d Mon Sep 17 00:00:00 2001 From: Barry Brands Date: Tue, 8 Oct 2024 15:37:15 +0200 Subject: [PATCH 4/6] Small fix --- src/Service/ZaakService.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Service/ZaakService.php b/src/Service/ZaakService.php index 2b82c8f..9972660 100644 --- a/src/Service/ZaakService.php +++ b/src/Service/ZaakService.php @@ -508,9 +508,7 @@ public function zaakHandler(?array $data = [], ?array $configuration = []) if (isset($data['caseId']) === true) { $zaak = $this->getZaak($configuration, $data['caseId']); - } - - if (isset($data['body']['case_uuid']) === true) { + } else if (isset($data['body']['case_uuid']) === true) { $zaak = $this->getZaak($configuration, $data['body']['case_uuid']); } From e3202f6d150baf7e7358c740ce455730cd1d4053 Mon Sep 17 00:00:00 2001 From: Barry Brands Date: Tue, 8 Oct 2024 18:41:17 +0200 Subject: [PATCH 5/6] Fix isset check and set correct value --- src/Service/ZaakService.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Service/ZaakService.php b/src/Service/ZaakService.php index 9972660..25a14d6 100644 --- a/src/Service/ZaakService.php +++ b/src/Service/ZaakService.php @@ -478,7 +478,7 @@ private function updateTaak(ObjectEntity $zaak, string $taakId): ObjectEntity $zaak = $this->resourceService->getObject($zaak->getId()->toString(), 'common-gateway/xxllnc-zgw-bundle'); $taak = $this->resourceService->getObject($taakId, 'common-gateway/xxllnc-zgw-bundle'); - $taak->setValue('url', $zaak->getValue('url')); + $taak->setValue('zaak', $zaak->getValue('url')); $this->entityManager->persist($taak); $this->entityManager->flush(); @@ -506,10 +506,16 @@ 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) { $zaak = $this->getZaak($configuration, $data['caseId']); - } else if (isset($data['body']['case_uuid']) === true) { - $zaak = $this->getZaak($configuration, $data['body']['case_uuid']); + } else if (isset($data['case_uuid']) === true) { + $zaak = $this->getZaak($configuration, $data['case_uuid']); } // Check if we already synced the zaak. From 73918857d97d5583092d35469dfcadbbb4464262 Mon Sep 17 00:00:00 2001 From: GitHub Actions <> Date: Tue, 8 Oct 2024 16:41:51 +0000 Subject: [PATCH 6/6] Update src from PHP Codesniffer --- src/Service/ZaakService.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Service/ZaakService.php b/src/Service/ZaakService.php index 25a14d6..bc99bb1 100644 --- a/src/Service/ZaakService.php +++ b/src/Service/ZaakService.php @@ -511,7 +511,6 @@ public function zaakHandler(?array $data = [], ?array $configuration = []) $data['case_uuid'] = $data['body']['case_uuid']; } - if (isset($data['caseId']) === true) { $zaak = $this->getZaak($configuration, $data['caseId']); } else if (isset($data['case_uuid']) === true) {