Skip to content

Commit e808515

Browse files
committed
Cleaned up handling of files "Recipient authority"
1 parent 8afb4c2 commit e808515

6 files changed

Lines changed: 43 additions & 5 deletions

File tree

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,17 @@ drush os2forms-fordelingskomponent
3535

3636
to see the list of Drush commands provided by the module.
3737

38+
## Generatings submissions
39+
40+
For testing and development, it may be useful to generate a number/lot of submissions on a webform. The
41+
[Webform](https://www.drupal.org/project/webform) and [Devel](https://www.drupal.org/project/devel) modules can help us
42+
do this:
43+
44+
``` shell
45+
drush pm:install webform_devel devel_generate
46+
drush webform:generate --help
47+
```
48+
3849
---
3950

4051
``` shell name=key-create-sf2900_certificate

drush.services.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ services:
3636
arguments:
3737
- '@Drupal\os2forms_fordelingskomponent\Helper\FordelingskomponentHelper'
3838
- '@Drupal\os2forms_fordelingskomponent\Settings'
39-
- '@entity_type.manager'
39+
- "@entity_type.manager"
4040
- '@Drupal\os2forms_fordelingskomponent\Helper\WebformHelperSF2900'
4141
tags:
4242
- { name: console.command }

src/Form/SettingsForm.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ private function buildFormSender(): array {
101101
$section[SenderSettings::ROUTING_MYNDIGHED] = [
102102
'#type' => 'textfield',
103103
'#title' => $this->t('Routing myndighed'),
104-
// '#required' => TRUE,
104+
'#required' => TRUE,
105105
'#default_value' => $settings->routingMyndighed,
106106
'#description' => $this->t('Default routing myndighed (CVR). May be overwritten by handler settings.'),
107107
];

src/Helper/FordelingskomponentHelper.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -755,10 +755,14 @@ private function buildTriggerFile(
755755

756756
$infRef = $handlerSettings->distributionObject->files->filspecifikation;
757757
$senderItSystem = $handlerSettings->sender->registreringItSystem;
758-
$senderAuthority = 'urn:oio:cvr-nr:' . $handlerSettings->sender->routingMyndighed;
758+
$senderAuthority = sprintf('urn:oio:cvr-nr:%08d', $handlerSettings->sender->routingMyndighed);
759759

760760
$recipientItSystem = trim((string) ($recipientItSystem ?? $handlerSettings->distributionObject->files->recipientItSystem));
761-
$recipientAuthority = 'urn:oio:cvr-nr:' . $handlerSettings->distributionObject->files->recipientAuthority;
761+
$recipientAuthority = trim($handlerSettings->distributionObject->files->recipientAuthority);
762+
if ('' === $recipientAuthority) {
763+
$recipientAuthority = $handlerSettings->sender->routingMyndighed;
764+
}
765+
$recipientAuthority = sprintf('urn:oio:cvr-nr:%08d', $recipientAuthority);
762766

763767
$routingInfo = (new SFTPDynamicRoutingInfoType())
764768
->setInfRef($infRef)

src/Plugin/WebformHandler/WebformHandlerSF2900.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,14 +279,34 @@ private function buildConfigurationFormDistributionObject(): array {
279279
],
280280
];
281281

282+
$section[DistributionObjectSettings::FILES][DistributionObjectFilesSettings::RECIPIENT_AUTHORITY_OVERRIDE] = [
283+
'#title' => $this->t('Set %recipient_authority', [
284+
'%recipient_authority' => $this->t('Recipient authority'),
285+
]),
286+
'#type' => 'checkbox',
287+
'#default_value' => $settings->files->recipientAuthorityOverride,
288+
'#description' => $this->t('If %recipient_authority is not set here, the global %routing_myndighed_label value (@routing_myndighed_value) will be used.', [
289+
'%recipient_authority' => $this->t('Recipient authority'),
290+
'%routing_myndighed_label' => $this->t('Routing myndighed'),
291+
'@routing_myndighed_value' => $this->settingsService->getSenderSettings()->routingMyndighed,
292+
]),
293+
];
282294
$section[DistributionObjectSettings::FILES][DistributionObjectFilesSettings::RECIPIENT_AUTHORITY] = [
283295
'#title' => $this->t('Recipient authority'),
284296
'#type' => 'textfield',
285297
'#attributes' => [
286298
'pattern' => DistributionObjectFilesSettings::RECIPIENT_AUTHORITY_PATTERN,
287299
],
288300
'#default_value' => $settings->files->recipientAuthority,
289-
'#description' => $this->t('CVR for recipient'),
301+
'#description' => $this->t('CVR for recipient.'),
302+
'#states' => [
303+
'visible' => [
304+
':input[name="settings[' . DistributionObjectSettings::NAME . '][' . DistributionObjectSettings::FILES . '][' . DistributionObjectFilesSettings::RECIPIENT_AUTHORITY_OVERRIDE . ']"]' => ['checked' => TRUE],
305+
],
306+
'required' => [
307+
':input[name="settings[' . DistributionObjectSettings::NAME . '][' . DistributionObjectSettings::FILES . '][' . DistributionObjectFilesSettings::RECIPIENT_AUTHORITY_OVERRIDE . ']"]' => ['checked' => TRUE],
308+
],
309+
],
290310
];
291311
$setStates($section[DistributionObjectSettings::FILES][DistributionObjectFilesSettings::RECIPIENT_AUTHORITY], [
292312
DistributionObjectSettings::DISTRIBUTION_TYPE_FORMULAR,

src/Settings/DistributionObjectSettings/FilesSettings.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ class FilesSettings extends AbstractSettings {
2020
public const string RECIPIENT_IT_SYSTEM_LOOK_UP = 'recipient_it_system_look_up';
2121
public bool $recipientItSystemLookUp = TRUE;
2222

23+
public const string RECIPIENT_AUTHORITY_OVERRIDE = 'recipient_authority_override';
24+
public bool $recipientAuthorityOverride = FALSE;
25+
2326
public const string RECIPIENT_AUTHORITY_PATTERN = self::CVR_PATTERN;
2427
public const string RECIPIENT_AUTHORITY = 'recipient_authority';
2528
public ?string $recipientAuthority = '';

0 commit comments

Comments
 (0)