File tree Expand file tree Collapse file tree 3 files changed +11
-3
lines changed
modules/os2forms_encrypt/src Expand file tree Collapse file tree 3 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,9 @@ before starting to add changes. Use example [placed in the end of the page](#exa
1111
1212## [ Unreleased]
1313
14+ - [ #123 ] ( https://github.com/OS2Forms/os2forms/pull/123 )
15+ Encrypt subelements
16+
1417## [ 3.15.6] 2024-07-16
1518
1619- [ #120 ] ( https://github.com/OS2Forms/os2forms/pull/120 )
Original file line number Diff line number Diff line change @@ -58,6 +58,11 @@ public function enabledEncrypt(): void {
5858
5959 $ defaultEncryptionProfile = $ config ->get ('default_encryption_profile ' );
6060
61+ if (!$ defaultEncryptionProfile ) {
62+ $ this ->output ()->writeln ('Default encryption profile is missing. Set one and try again. ' );
63+ return ;
64+ }
65+
6166 // Get the storage for Webform entity type.
6267 $ webformStorage = $ this ->entityTypeManager ->getStorage ('webform ' );
6368
@@ -66,12 +71,12 @@ public function enabledEncrypt(): void {
6671
6772 /** @var \Drupal\webform\Entity\Webform $webform */
6873 foreach ($ webforms as $ webform ) {
69- $ elements = $ webform ->getElementsDecoded ();
74+ $ elements = $ webform ->getElementsDecodedAndFlattened ();
7075 $ config = $ webform ->getThirdPartySettings ('webform_encrypt ' );
7176
7277 $ changed = FALSE ;
7378 foreach ($ elements as $ key => $ element ) {
74- if (!isset ($ config ['element ' ][$ key ])) {
79+ if (!isset ($ config ['element ' ][$ key ]) || $ config [ ' element ' ][ $ key ][ ' encrypt_profile ' ] === NULL ) {
7580 $ config ['element ' ][$ key ] = [
7681 'encrypt ' => TRUE ,
7782 'encrypt_profile ' => $ defaultEncryptionProfile ,
Original file line number Diff line number Diff line change @@ -89,7 +89,7 @@ public function enableEncryption(WebformInterface $webform): void {
8989 }
9090
9191 // Check that there are any elements to enable encryption on.
92- $ elements = $ webform ->getElementsDecoded ();
92+ $ elements = $ webform ->getElementsDecodedAndFlattened ();
9393
9494 if (empty ($ elements )) {
9595 return ;
You can’t perform that action at this time.
0 commit comments