Skip to content

Commit

Permalink
Merge pull request #27155 from totten/5.64-afform-token
Browse files Browse the repository at this point in the history
(dev/core#4531) Afform Mail Tokens - Fix rendering for localized/individual email
  • Loading branch information
eileenmcnaughton authored Aug 25, 2023
2 parents 6143bdf + 8224bb1 commit 4d1e1c5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
17 changes: 16 additions & 1 deletion ext/afform/core/Civi/Afform/Tokens.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,32 @@
namespace Civi\Afform;

use Civi\Core\Event\GenericHookEvent;
use Civi\Core\Service\AutoService;
use Civi\Crypto\Exception\CryptoException;
use CRM_Afform_ExtensionUtil as E;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

/**
* Every afform with the property `is_token=true` should have a corresponding
* set of tokens, `{afform.myFormUrl}` and `{afform.myFormLink}`.
*
* @see MockPublicFormTest
* @package Civi\Afform
* @service civi.afform.tokens
*/
class Tokens {
class Tokens extends AutoService implements EventSubscriberInterface {

public static function getSubscribedEvents(): array {
if (!\CRM_Extension_System::singleton()->getMapper()->isActiveModule('authx')) {
return [];
}

return [
'hook_civicrm_alterMailContent' => 'applyCkeditorWorkaround',
'hook_civicrm_tokens' => 'hook_civicrm_tokens',
'hook_civicrm_tokenValues' => 'hook_civicrm_tokenValues',
];
}

/**
* CKEditor makes it hard to set an `href` to a token, so we often get
Expand Down
7 changes: 0 additions & 7 deletions ext/afform/core/afform.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,6 @@ function afform_civicrm_config(&$config) {
$dispatcher->addListener('hook_civicrm_alterAngular', ['\Civi\Afform\AfformMetadataInjector', 'preprocess']);
$dispatcher->addListener('hook_civicrm_check', ['\Civi\Afform\StatusChecks', 'hook_civicrm_check']);
$dispatcher->addListener('civi.afform.get', ['\Civi\Api4\Action\Afform\Get', 'getCustomGroupBlocks']);

// Register support for email tokens
if (CRM_Extension_System::singleton()->getMapper()->isActiveModule('authx')) {
$dispatcher->addListener('hook_civicrm_alterMailContent', ['\Civi\Afform\Tokens', 'applyCkeditorWorkaround']);
$dispatcher->addListener('hook_civicrm_tokens', ['\Civi\Afform\Tokens', 'hook_civicrm_tokens']);
$dispatcher->addListener('hook_civicrm_tokenValues', ['\Civi\Afform\Tokens', 'hook_civicrm_tokenValues']);
}
}

/**
Expand Down

0 comments on commit 4d1e1c5

Please sign in to comment.