Skip to content

Commit

Permalink
Added xmlEncode actionHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
WilcoLouwerse committed Feb 15, 2024
1 parent 03cc73c commit e8358ec
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Installation/Action/ZgwZaakToZdsXmlEncodeAction.action.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"title": "ZgwZaakToZdsXmlEncodeAction.action.json",
"$id": "https://dowr.simxml.nl/action/ZgwZaakToZdsXmlEncodeAction.action.json.action.json",
"$schema": "https://docs.commongateway.nl/schemas/Action.schema.json",
"version": "0.0.1",
"listens": [
"zgwToZds.xmlEncode"
],
"conditions": {
"==": [1,1]
},
"class": "CommonGateway\\ZGWToZDSBundle\\ActionHandler\\ZgwToZDSXMLEncodeHandler"
}
3 changes: 3 additions & 0 deletions Installation/installation.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
"path": "stuf/zds/requests",
"methods": [
"POST"
],
"throws": [
"zgwToZds.xmlEncode"
]
}
]
Expand Down
76 changes: 76 additions & 0 deletions src/ActionHandler/ZgwToZDSXMLEncodeHandler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?php

Check failure on line 2 in src/ActionHandler/ZgwToZDSXMLEncodeHandler.php

View workflow job for this annotation

GitHub Actions / build

Missing file doc comment
namespace CommonGateway\ZGWToZDSBundle\ActionHandler;

use CommonGateway\CoreBundle\ActionHandler\ActionHandlerInterface;
use CommonGateway\ZGWToZDSBundle\Service\ZGWToZDSService;


/**
* An action handler that does an xmlEncode on a proxy response after mapping returns json instead of xml. (temporary solution)

Check warning on line 10 in src/ActionHandler/ZgwToZDSXMLEncodeHandler.php

View workflow job for this annotation

GitHub Actions / build

Line exceeds 125 characters; contains 127 characters
* todo: add option to recognize we need to xml encode at the end of handleEndpointsConfigIn function in CoreBundle CallService.

Check warning on line 11 in src/ActionHandler/ZgwToZDSXMLEncodeHandler.php

View workflow job for this annotation

GitHub Actions / build

Line exceeds 125 characters; contains 128 characters

Check warning on line 11 in src/ActionHandler/ZgwToZDSXMLEncodeHandler.php

View workflow job for this annotation

GitHub Actions / build

Comment refers to a TODO task "add option to recognize we need to xml encode at the end of handleEndpointsConfigIn function in CoreBundle CallService"
*
* @author Conduction.nl <info@conduction.nl>, Wilco Louwerse <wilco@conduction.nl>
* @license EUPL-1.2 https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
*/
class ZgwToZDSXMLEncodeHandler implements ActionHandlerInterface
{

/**
* The zgw to zds service used by the handler
*
* @var ZGWToZDSService
*/
private ZGWToZDSService $service;


/**
* The constructor
*
* @param ZGWToZDSService $service The zgw to zds service
*/
public function __construct(ZGWToZDSService $service)
{
$this->service = $service;

}//end __construct()


/**
* Returns the required configuration as a https://json-schema.org array.
*
* @return array The configuration that this action should comply to
*/
public function getConfiguration(): array
{
return [
'$id' => 'https://example.com/ActionHandler/ZGWToZDSHandler.ActionHandler.json',
'$schema' => 'https://docs.commongateway.nl/schemas/ActionHandler.schema.json',
'title' => 'ZGW Zaak to ZDS XmlEncode ActionHandler',
'description' => 'ZGW Zaak to ZDS XmlEncode ActionHandler',
'required' => [],
'properties' => [],
];

}//end getConfiguration()


/**
* This function runs the service.
*
* @param array $data The data from the call
* @param array $configuration The configuration of the action
*
* @return array
*
* @SuppressWarnings("unused") Handlers ara strict implementations
*/
public function run(array $data, array $configuration): array
{

return $this->service->zgwToZdsXmlEncodeHandler($data, $configuration);

}//end run()


}//end class
16 changes: 16 additions & 0 deletions src/Service/ZGWToZDSService.php
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,22 @@ public function zgwToZdsInformationObjectHandler(array $data, array $configurati
return $data;

}//end zgwToZdsInformationObjectHandler()

/**
* Does an xmlEncode on the response data. (temporary solution)
*
* @param array $data The data array.
* @param array $configuration The configuration array.
*
* @return array The updated data array.
*/
public function zgwToZdsXmlEncodeHandler(array $data, array $configuration): array

Check warning on line 342 in src/Service/ZGWToZDSService.php

View workflow job for this annotation

GitHub Actions / build

Avoid unused parameters such as '$configuration'.
{
// $encoder = new XmlEncoder(['xml_root_node_name' => 'SOAP-ENV:Envelope']);
// $message = $encoder->encode($data['response'], 'xml');

return $data;
}


}//end class

0 comments on commit e8358ec

Please sign in to comment.