+ /**
+ * Get token deprecation information.
+ *
+ * @return array
+ */
+ public static function getTokenDeprecations(): array {
+ return [
+ 'WorkFlowMessageTemplates' => [
+ 'contribution_invoice_receipt' => [
+ '$display_name' => 'contact.display_name',
+ ],
+ 'contribution_online_receipt' => [
+ '$contributeMode' => 'no longer available / relevant',
+ '$first_name' => 'contact.first_name',
+ '$last_name' => 'contact.last_name',
+ '$displayName' => 'contact.display_name',
+ ],
+ ],
+ ];
+ }
+
+ /**
+ * Get the tokens available for the domain.
+ *
+ * @param int $domainID
+ * @param bool $html
+ *
+ * @return array
+ * @throws \CRM_Core_Exception
+ */
+ protected static function getDomainTokens(int $domainID, bool $html): array {
+ $cacheKey = __CLASS__ . 'domain_tokens' . $html . '_' . $domainID . '_' . CRM_Core_I18n::getLocale();
+ if (!Civi::cache('metadata')->has($cacheKey)) {
+ if (CRM_Core_Config::domainID() === $domainID) {
+ $domain = CRM_Core_BAO_Domain::getDomain();
+ }
+ else {
+ $domain = new CRM_Core_BAO_Domain();
+ $domain->find(TRUE);
+ }
+ $tokens = [
+ 'name' => $domain->name,
+ 'id' => $domain->id,
+ 'description' => $domain->description,
+ ];
+ $loc = $domain->getLocationValues();
+ if ($html) {
+ $tokens['address'] = str_replace("\n", '<br />', ($loc['address'][1]['display'] ?? ''));
+ }
+ else {
+ $tokens['address'] = $loc['address'][1]['display_text'] ?? '';
+ }
+ $phone = reset($loc['phone']);
+ $email = reset($loc['email']);
+ $tokens['phone'] = $phone['phone'] ?? '';
+ $tokens['email'] = $email['email'] ?? '';
+ Civi::cache('metadata')->set($cacheKey, $tokens);
+ }
+ return Civi::cache('metadata')->get($cacheKey);
+ }
+