Skip to content

Commit

Permalink
Prevent objects from being created multiple times
Browse files Browse the repository at this point in the history
  • Loading branch information
rjzondervan committed Oct 4, 2024
1 parent 05c15d8 commit df2fced
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/Service/NewSynchronizationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use App\Service\SynchronizationService;
use CommonGateway\CoreBundle\Service\CallService;
use CommonGateway\CoreBundle\Service\GatewayResourceService;
use CommonGateway\CoreBundle\Service\HydrationService;
use CommonGateway\CoreBundle\Service\MappingService;
use DateInterval;
use DateTime;
Expand Down Expand Up @@ -41,6 +42,7 @@ public function __construct(
private readonly LoggerInterface $synchronizationLogger,

Check warning on line 42 in src/Service/NewSynchronizationService.php

View workflow job for this annotation

GitHub Actions / build

Avoid excessively long variable names like $synchronizationLogger. Keep variable name length under 20.
private readonly EntityManagerInterface $entityManager,
private readonly MappingService $mappingService,
private readonly HydrationService $hydrationService,
) {

}//end __construct()
Expand Down Expand Up @@ -118,7 +120,8 @@ public function synchronizeFromSource(Synchronization $synchronization, array $s
$sourceObject = $this->mappingService->mapping($synchronization->getMapping(), $sourceObject);
}

$synchronization->getObject()->hydrate($sourceObject, $unsafe);
$object = $this->hydrationService->searchAndReplaceSynchronizations(object: $sourceObject, source: $synchronization->getSource(), entity: $synchronization->getEntity(), flush: false);
$synchronization->setObject($object);

$synchronization->setSha($sha);

Expand Down Expand Up @@ -183,8 +186,19 @@ public function synchronizeCollectionHandler(array $data, array $configuration):
$source = $this->resourceService->getSource(reference: $configuration['source'], pluginName: "common-gateway/vrijbrp-to-zgw-bundle");

Check warning on line 186 in src/Service/NewSynchronizationService.php

View workflow job for this annotation

GitHub Actions / build

Line exceeds 125 characters; contains 141 characters
$schema = $this->resourceService->getSchema(reference: $configuration['schema'], pluginName: "common-gateway/vrijbrp-to-zgw-bundle");

Check warning on line 187 in src/Service/NewSynchronizationService.php

View workflow job for this annotation

GitHub Actions / build

Line exceeds 125 characters; contains 141 characters

if($source === null) {
return $data;
}
if($schema === null) {
return $data;
}

if (isset($configuration['mapping']) === true) {
$mapping = $this->resourceService->getMapping(reference: $configuration['mapping'], pluginName: "common-gateway/vrijbrp-to-zgw-bundle");

Check warning on line 197 in src/Service/NewSynchronizationService.php

View workflow job for this annotation

GitHub Actions / build

Line exceeds 125 characters; contains 148 characters

if($mapping === null) {
return $data;
}
}

try {
Expand Down

0 comments on commit df2fced

Please sign in to comment.