Skip to content

Commit

Permalink
use Request to evaluate host, fix warning in Tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
koertho committed Jun 30, 2022
1 parent d03b2d5 commit cdf1198
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to this project will be documented in this file.

## [1.23.3] - 2022-06-30
- Fixed: empty host in optInUrl in some cases
- Fixed: warning in Tokens

## [1.23.2] - 2022-06-28
- Changed: type hint to be less restrictive in Tokens

Expand Down
3 changes: 2 additions & 1 deletion classes/EventListener/FormGeneratorListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,9 @@ public function onSendNotificationMessage(Message $message, array &$tokens, ?str

if (version_compare(VERSION, '4.7', '>=')) {
if (($tokens['formconfig_huhSubAddOptIn'] ?? false) && isset($tokens['formconfig_optInIdentifier'])) {
$base = System::getContainer()->get('request_stack')->getCurrentRequest()->getSchemeAndHttpHost();
$tokens['optInToken'] = $tokens['formconfig_optInIdentifier'];
$tokens['optInUrl'] = Environment::get('base').'?token='.$tokens['formconfig_optInIdentifier'];
$tokens['optInUrl'] = $base.'?token='.$tokens['formconfig_optInIdentifier'];
}
}

Expand Down
11 changes: 7 additions & 4 deletions classes/util/Tokens.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,15 @@ public static function cleanInvalidTokens(array $tokens): array
return $tokens;
}


public static function addAttachmentTokens(array $tokens, ?array $files): array
{
foreach ($files as $fieldName => $fileData) {
$fileModel = FilesModel::findByUuid($fileData['uuid']);
if ($fileModel) {
$tokens['attachment_'.$fieldName] = $fileModel->path;
if (!empty($files)) {
foreach ($files as $fieldName => $fileData) {
$fileModel = FilesModel::findByUuid($fileData['uuid']);
if ($fileModel) {
$tokens['attachment_'.$fieldName] = $fileModel->path;
}
}
}

Expand Down

0 comments on commit cdf1198

Please sign in to comment.