Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encrypt subelements #123

Merged
merged 3 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ before starting to add changes. Use example [placed in the end of the page](#exa

## [Unreleased]

- [#123](https://github.com/OS2Forms/os2forms/pull/123)
Encrypt subelements

## [3.15.6] 2024-07-16

- [#120](https://github.com/OS2Forms/os2forms/pull/120)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ public function enabledEncrypt(): void {

$defaultEncryptionProfile = $config->get('default_encryption_profile');

if (!$defaultEncryptionProfile) {
$this->output()->writeln('Default encryption profile is missing. Set one and try again.');
return;
}

// Get the storage for Webform entity type.
$webformStorage = $this->entityTypeManager->getStorage('webform');

Expand All @@ -66,12 +71,12 @@ public function enabledEncrypt(): void {

/** @var \Drupal\webform\Entity\Webform $webform */
foreach ($webforms as $webform) {
$elements = $webform->getElementsDecoded();
$elements = $webform->getElementsDecodedAndFlattened();
$config = $webform->getThirdPartySettings('webform_encrypt');

$changed = FALSE;
foreach ($elements as $key => $element) {
if (!isset($config['element'][$key])) {
if (!isset($config['element'][$key]) || $config['element'][$key]['encrypt_profile'] === NULL) {
$config['element'][$key] = [
'encrypt' => TRUE,
'encrypt_profile' => $defaultEncryptionProfile,
Expand Down
2 changes: 1 addition & 1 deletion modules/os2forms_encrypt/src/Helper/Os2FormsEncryptor.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function enableEncryption(WebformInterface $webform): void {
}

// Check that there are any elements to enable encryption on.
$elements = $webform->getElementsDecoded();
$elements = $webform->getElementsDecodedAndFlattened();

if (empty($elements)) {
return;
Expand Down
Loading