generated from CommonGateway/PetStoreBundle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Preliminary fixes for blocking deletes and overriding values by defaults
- Loading branch information
1 parent
098a52a
commit 2b79ec5
Showing
5 changed files
with
224 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?php | ||
|
||
namespace CommonGateway\ZGWBundle\ActionHandler; | ||
|
||
use App\Exception\GatewayException; | ||
use CommonGateway\CoreBundle\ActionHandler\ActionHandlerInterface; | ||
use CommonGateway\ZGWBundle\Service\ZGWService; | ||
use Psr\Cache\CacheException; | ||
use Psr\Cache\InvalidArgumentException; | ||
use Respect\Validation\Exceptions\ComponentException; | ||
|
||
class DeleteHandler implements ActionHandlerInterface | ||
{ | ||
private ZGWService $zgwService; | ||
|
||
public function __construct(ZGWService $zgwService) | ||
{ | ||
$this->zgwService = $zgwService; | ||
} | ||
|
||
/** | ||
* This function returns the requered configuration as a [json-schema](https://json-schema.org/) array. | ||
* | ||
* @throws array a [json-schema](https://json-schema.org/) that this action should comply to | ||
*/ | ||
public function getConfiguration(): array | ||
{ | ||
return [ | ||
'$id' => 'https://example.com/person.schema.json', | ||
'$schema' => 'https://docs.commongateway.nl/schemas/ActionHandler.schema.json', | ||
'title' => 'ZGW Action', | ||
'description' => 'This handler returns a welcoming string', | ||
'required' => [], | ||
'properties' => [ | ||
'schema' => [ | ||
'type' => 'string', | ||
'description' => 'The reference to the schema to block deletes for', | ||
'example' => 'https://vng.opencatalogi.nl/schemas/ztc.zaakType.schema.json', | ||
'nullable' => true, | ||
], | ||
'property' => [ | ||
'type' => 'string', | ||
'description' => 'The property of the schema that can block deletion.', | ||
'example' => 'concept', | ||
'nullable' => true, | ||
], | ||
'value' => [ | ||
'type' => 'boolean', | ||
'description' => 'The value that blocks deletion of an object.', | ||
'example' => false, | ||
'nullable' => true, | ||
], | ||
|
||
], | ||
]; | ||
} | ||
|
||
/** | ||
* This function runs the service. | ||
* | ||
* @param array $data The data from the call | ||
* @param array $configuration The configuration of the action | ||
* | ||
* @throws GatewayException | ||
* @throws CacheException | ||
* @throws InvalidArgumentException | ||
* @throws ComponentException | ||
* | ||
* @return array | ||
*/ | ||
public function run(array $data, array $configuration): array | ||
{ | ||
return $this->zgwService->preventDeleteHandler($data, $configuration); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
|
||
namespace CommonGateway\ZGWBundle\ActionHandler; | ||
|
||
use App\Exception\GatewayException; | ||
use CommonGateway\CoreBundle\ActionHandler\ActionHandlerInterface; | ||
use CommonGateway\ZGWBundle\Service\ZGWService; | ||
use Psr\Cache\CacheException; | ||
use Psr\Cache\InvalidArgumentException; | ||
use Respect\Validation\Exceptions\ComponentException; | ||
|
||
class IdentificatieHandler implements ActionHandlerInterface | ||
{ | ||
private ZGWService $zgwService; | ||
|
||
public function __construct(ZGWService $zgwService) | ||
{ | ||
$this->zgwService = $zgwService; | ||
} | ||
|
||
/** | ||
* This function returns the requered configuration as a [json-schema](https://json-schema.org/) array. | ||
* | ||
* @throws array a [json-schema](https://json-schema.org/) that this action should comply to | ||
*/ | ||
public function getConfiguration(): array | ||
{ | ||
return [ | ||
'$id' => 'https://example.com/person.schema.json', | ||
'$schema' => 'https://docs.commongateway.nl/schemas/ActionHandler.schema.json', | ||
'title' => 'ZGW Action', | ||
'description' => 'This handler returns a welcoming string', | ||
'required' => [], | ||
'properties' => [ | ||
'schema' => [ | ||
'type' => 'string', | ||
'description' => 'The reference to the schema to update.', | ||
'example' => 'https://vng.opencatalogi.nl/schemas/zrc.zaak.schema.json', | ||
'nullable' => true, | ||
], | ||
'property' => [ | ||
'type' => 'string', | ||
'description' => 'The property to override.', | ||
'example' => 'identificatie', | ||
'nullable' => true, | ||
], | ||
'value' => [ | ||
'type' => 'string', | ||
'description' => 'The value that should be overridden.', | ||
'example' => '', | ||
'nullable' => true, | ||
], | ||
], | ||
]; | ||
} | ||
|
||
/** | ||
* This function runs the service. | ||
* | ||
* @param array $data The data from the call | ||
* @param array $configuration The configuration of the action | ||
* | ||
* @throws GatewayException | ||
* @throws CacheException | ||
* @throws InvalidArgumentException | ||
* @throws ComponentException | ||
* | ||
* @return array | ||
*/ | ||
public function run(array $data, array $configuration): array | ||
{ | ||
return $this->zgwService->overrideValueHandler($data, $configuration); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"title": "ZaakZoekenAction", | ||
"$id": "https://vng.opencatalogi.nl/action/zgw.blockDeleteAction.action.json", | ||
"$schema": "https://docs.commongateway.nl/schemas/Action.schema.json", | ||
"version": "0.0.1", | ||
"listens": ["commongateway.object.pre.delete"], | ||
"conditions": | ||
{ | ||
"==": [ | ||
1,1 | ||
] | ||
}, | ||
"class": "CommonGateway\\ZGWBundle\\ActionHandler\\DeleteHandler", | ||
"configuration": { | ||
"schema": "https://vng.opencatalogi.nl/schemas/ztc.zaakType.schema.json", | ||
"property": "concept", | ||
"value": false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"title": "ZaakZoekenAction", | ||
"$id": "https://vng.opencatalogi.nl/action/zgw.blockDeleteAction.action.json", | ||
"$schema": "https://docs.commongateway.nl/schemas/Action.schema.json", | ||
"version": "0.0.1", | ||
"listens": ["commongateway.object.pre.create"], | ||
"conditions": | ||
{ | ||
"==": [ | ||
1,1 | ||
] | ||
}, | ||
"class": "CommonGateway\\ZGWBundle\\ActionHandler\\IdentificatieHandler", | ||
"configuration": { | ||
"schema": "https://vng.opencatalogi.nl/schemas/zrc.zaak.schema.json", | ||
"property": "identificatie", | ||
"value": "" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters