Skip to content

Commit

Permalink
Fixes from tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rjzondervan committed Sep 30, 2024
1 parent 51acdf1 commit 7812fa4
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 29 deletions.
2 changes: 1 addition & 1 deletion Installation/Action/synczaken.action.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"title": "Sync Cases from VrijBRP",
"$id": "https://vrijbrp.nl/action/vrijbrp.synczaken.action.json",
"$schema": "https://docs.commongateway.nl/schemas/Action.schema.json",
"version": "0.0.3",
"version": "0.0.1",
"listens": [
"vrijbrp.zaken.sync"
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
"version": "0.0.1",
"description": "This is an example Action. This action is triggered when commongateway.object.create event is thrown and the data (object) of the event has entity = https://example.com/schema/example.schema.json. In order for this condition to work the ref https://example.com/schema/example.schema.json has to be translated to an id, see installation.json['actions']['fixConfigRef'] for how to do this.",
"listens": [
"commongateway.object.pre.update"
"commongateway.object.pre.create"
],
"conditions":
{
"==": [
{
"var": "entity.reference"
}, "https://vng.opencatalogi.nl/schemas/zrc.zaak.schema.json"
}, "https://vng.opencatalogi.nl/schemas/zrc.status.schema.json"
]
},
"class": "CommonGateway\\VrijBRPToZGWBundle\\ActionHandler\\NotificationUpdateHandler",
Expand Down
46 changes: 20 additions & 26 deletions src/Service/VrijBrpService.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class VrijBrpService


public function __construct(

Check failure on line 15 in src/Service/VrijBrpService.php

View workflow job for this annotation

GitHub Actions / build

Missing doc comment for function __construct()
private readonly CacheService $cacheService,
private readonly CacheService $cacheService,
private readonly GatewayResourceService $resourceService,
private readonly EntityManagerInterface $entityManager,
) {
Expand Down Expand Up @@ -73,34 +73,28 @@ function arrayRecursiveDiff($aArray1, $aArray2)

public function createNotification(array $data, array $config): array
{
var_dump('hello');

$object = $data['object'];

if ($object instanceof ObjectEntity) {
$data = $object->toArray(['embedded' => true, 'user' => $this->cacheService->getObjectUser(objectEntity: $object)]);
$oldData = $this->cacheService->getObject($object->getId());

$diff = $this->arrayRecursiveDiff($data, $oldData);

if (array_key_exists(key: 'status', array: $diff) === true) {
$now = new DateTime();
$message = [
'kanaal' => 'zaak.status.created',
'hoofdobject' => $data['url'],
'resource' => 'Zaak',
'resourceUrl' => $data['url'],
'actie' => 'create',
'aanmaakdatum' => $now->format('c'),
];
$schema = $this->resourceService->getSchema(
reference:'https://zgw.opencatalogi.nl/schema/nrc.message.schema.json',
pluginName: 'common-gateway/vrijbrp-to-zgw-bundle'
);
$messageObject = new ObjectEntity(entity: $schema);
$messageObject->hydrate($message);
$this->entityManager->persist($messageObject);
}
$objectData = $object->toArray(['embedded' => true, 'user' => $this->cacheService->getObjectUser(objectEntity: $object)]);

Check warning on line 79 in src/Service/VrijBrpService.php

View workflow job for this annotation

GitHub Actions / build

Line exceeds 125 characters; contains 134 characters

$now = new DateTime();

Check warning on line 81 in src/Service/VrijBrpService.php

View workflow job for this annotation

GitHub Actions / build

Equals sign not aligned with surrounding assignments; expected 11 spaces but found 1 space
$message = [

Check warning on line 82 in src/Service/VrijBrpService.php

View workflow job for this annotation

GitHub Actions / build

Equals sign not aligned with surrounding assignments; expected 7 spaces but found 1 space
'kanaal' => 'zaak.status.created',
'hoofdobject' => $objectData['zaak'],
'resource' => 'Zaak',
'resourceUrl' => $objectData['zaak'],
'actie' => 'create',
'aanmaakdatum' => $now->format('c'),
];
$schema = $this->resourceService->getSchema(

Check warning on line 90 in src/Service/VrijBrpService.php

View workflow job for this annotation

GitHub Actions / build

Equals sign not aligned with surrounding assignments; expected 8 spaces but found 1 space
reference: 'https://zgw.opencatalogi.nl/schema/nrc.message.schema.json',
pluginName: 'common-gateway/vrijbrp-to-zgw-bundle'
);
$messageObject = new ObjectEntity(entity: $schema);
$messageObject->hydrate($message);
$this->entityManager->persist($messageObject);

}//end if

return $data;
Expand Down

0 comments on commit 7812fa4

Please sign in to comment.