Skip to content

Commit

Permalink
#446: Handle os2forms_attachment
Browse files Browse the repository at this point in the history
  • Loading branch information
jekuaitk committed Jan 10, 2024
1 parent 32fa7c1 commit 1348899
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 11 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ about writing changes to this log.

## [Unreleased]

## [2.0.2]

- Added `OS2Forms Attachment` to attachments data.

## [2.0.1]

- Updated module config with new list submissions endpoint
Expand All @@ -28,7 +32,8 @@ about writing changes to this log.

- Release 1.0.0

[Unreleased]: https://github.com/OS2Forms/os2forms_rest_api/compare/2.0.1...HEAD
[Unreleased]: https://github.com/OS2Forms/os2forms_rest_api/compare/2.0.2...HEAD
[2.0.2]: https://github.com/OS2Forms/os2forms_rest_api/compare/2.0.1...2.0.2
[2.0.1]: https://github.com/OS2Forms/os2forms_rest_api/compare/2.0.0...2.0.1
[2.0.0]: https://github.com/OS2Forms/os2forms_rest_api/compare/1.1.0...2.0.0
[1.1.0]: https://github.com/OS2Forms/os2forms_rest_api/compare/1.0.0...1.1.0
Expand Down
15 changes: 5 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"require": {
"cweagans/composer-patches": "^1.7",
"drupal/key_auth": "^2.0",
"drupal/webform_rest": "^4.0"
"drupal/webform_rest": "^4.1",
"os2forms/os2forms": "^3.13"
},
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.2",
Expand Down Expand Up @@ -51,15 +52,9 @@
"sort-packages": true,
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true,
"cweagans/composer-patches": true
}
},
"extra": {
"enable-patching": true,
"patches": {
"drupal/webform_rest": {
"Added ability to modify response data sent from Webform Submission endpoint": "https://raw.githubusercontent.com/OS2Forms/os2forms_rest_api/1.1.0/patches/webform_rest_submission.patch"
}
"cweagans/composer-patches": true,
"zaporylie/composer-drupal-optimizations": true,
"simplesamlphp/composer-module-installer": true
}
}
}
1 change: 1 addition & 0 deletions os2forms_rest_api.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ dependencies:
- drupal:key_auth
- drupal:webform
- drupal:webform_rest
- os2forms:os2forms_attachment
8 changes: 8 additions & 0 deletions src/EventSubscriber/WebformSubmissionDataEventSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\file\FileInterface;
use Drupal\os2forms_attachment\Element\AttachmentElement;
use Drupal\webform\WebformInterface;
use Drupal\webform\WebformSubmissionInterface;
use Drupal\webform_entity_print_attachment\Element\WebformEntityPrintAttachment;
Expand Down Expand Up @@ -145,6 +146,13 @@ private function buildAttachments(WebformSubmissionInterface $submission, array
'type' => $type,
'url' => $url->toString(TRUE)->getGeneratedUrl(),
];
} elseif ('os2forms_attachment' === $element['#type']) {
$url = AttachmentElement::getFileUrl($element, $submission);
$attachments[$key] = [
'name' => $element['#title'] ?? $name,
'type' => $element['#export_type'] ?? '',
'url' => $url->toString(TRUE)->getGeneratedUrl(),
];
}
}

Expand Down

0 comments on commit 1348899

Please sign in to comment.