This should fix a failure in `TokenConsistencyTest`. Setting a breakpoint and monitoring
`$contactDetails`, it appears that the data would come in multiple formats. (Sometimes as
a nested array; sometimes as a flatter array.) This makes it work with both cases.
$greetingTokens = self::getTokens($tokenString);
$context = $contactId ? ['contactId' => $contactId] : [];
if ($contactDetails) {
- foreach ($contactDetails[0] as $contact) {
- // Only 1 - the loop is because we may not know the id.
- $context['contact'] = $contact;
- }
+ $context['contact'] = isset($contactDetails[0]) ? reset($contactDetails[0]) : $contactDetails;
}
$tokenProcessor = new TokenProcessor(\Civi::dispatcher(), [
'smarty' => FALSE,