* Domain tokens
*
* @return array
+ *
+ * @deprecated
*/
public static function domainTokens() {
- return [
- '{domain.name}' => ts('Domain name'),
- '{domain.address}' => ts('Domain (organization) address'),
- '{domain.phone}' => ts('Domain (organization) phone'),
- '{domain.email}' => ts('Domain (organization) email'),
- ];
+ $tokenProcessor = new TokenProcessor(Civi::dispatcher(), []);
+ return $tokenProcessor->listTokens();
}
/**
/**
* Different type of Event Tokens.
*
+ * @deprecated
+ *
* @return array
*/
- public static function eventTokens() {
- return [
- '{event.event_id}' => ts('Event ID'),
- '{event.title}' => ts('Event Title'),
- '{event.start_date}' => ts('Event Start Date'),
- '{event.end_date}' => ts('Event End Date'),
- '{event.event_type}' => ts('Event Type'),
- '{event.summary}' => ts('Event Summary'),
- '{event.contact_email}' => ts('Event Contact Email'),
- '{event.contact_phone}' => ts('Event Contact Phone'),
- '{event.description}' => ts('Event Description'),
- '{event.location}' => ts('Event Location'),
- '{event.fee_amount}' => ts('Event Fees'),
- '{event.info_url}' => ts('Event Info URL'),
- '{event.registration_url}' => ts('Event Registration URL'),
- '{event.balance}' => ts('Event Balance'),
- ];
+ public static function eventTokens(): array {
+ $tokenProcessor = new TokenProcessor(Civi::dispatcher(), ['schema' => ['eventId']]);
+ $allTokens = $tokenProcessor->listTokens();
+ foreach (array_keys($allTokens) as $token) {
+ if (strpos($token, '{domain.') === 0) {
+ unset($allTokens[$token]);
+ }
+ }
+ return $allTokens;
}
/**
* Different type of Contribution Tokens.
*
+ * @deprecated
+ *
* @return array
*/
public static function contributionTokens(): array {
$tokenProcessor = new TokenProcessor(Civi::dispatcher(), ['schema' => ['contributionId']]);
- return $tokenProcessor->listTokens();
+ $allTokens = $tokenProcessor->listTokens();
+ foreach (array_keys($allTokens) as $token) {
+ if (strpos($token, '{domain.') === 0) {
+ unset($allTokens[$token]);
+ }
+ }
+ return $allTokens;
}
/**
* Different type of Contact Tokens.
*
+ * @deprecated
+ *
* @return array
*/
public static function contactTokens(): array {
$tokenProcessor = new TokenProcessor(Civi::dispatcher(), ['schema' => ['contactId']]);
- return $tokenProcessor->listTokens();
+ $allTokens = $tokenProcessor->listTokens();
+ foreach (array_keys($allTokens) as $token) {
+ if (strpos($token, '{domain.') === 0) {
+ unset($allTokens[$token]);
+ }
+ }
+ return $allTokens;
}
/**
'{participant.participant_registered_by_id}' => 'Registered By Participant ID',
'{participant.transferred_to_contact_id}' => 'Transferred to Contact ID',
'{participant.participant_role}' => 'Participant Role (label)',
- '{participant.event_title}' => 'Event Title',
- '{participant.event_start_date}' => 'Event Start Date',
- '{participant.event_end_date}' => 'Event End Date',
'{participant.fee_label}' => 'Fee Label',
'{participant.default_role_id}' => 'Default Role',
'{participant.template_title}' => 'Event Template Title',
- '{participant.currency}' => 'Currency',
- '{participant.participant_note}' => 'Participant Note',
];
$customFields = CRM_Core_BAO_CustomField::getFields('Participant');
'smarty' => FALSE,
'schema' => ['caseId'],
]);
- $this->assertEquals($expectedTokens, $tokenProcessor->listTokens());
+ $this->assertEquals(array_merge($expectedTokens, $this->getDomainTokens()), $tokenProcessor->listTokens());
$tokenProcessor->addRow([
'caseId' => $this->getCaseID(),
]);
'smarty' => FALSE,
'schema' => ['contribution_recurId'],
]);
- $this->assertEquals($this->getContributionRecurTokens(), $tokenProcessor->listTokens());
+ $this->assertEquals(array_merge($this->getContributionRecurTokens(), $this->getDomainTokens()), $tokenProcessor->listTokens());
$tokenString = implode("\n", array_keys($this->getContributionRecurTokens()));
$tokenProcessor->addMessage('html', $tokenString, 'text/plain');
$tokens = $tokenProcessor->listTokens();
// Add in custom tokens as token processor supports these.
$expectedTokens['{membership.custom_1}'] = 'Enter text here :: Group with field text';
- $this->assertEquals($expectedTokens, $tokens);
+ $this->assertEquals(array_merge($expectedTokens, $this->getDomainTokens()), $tokens);
$tokenProcessor->addMessage('html', $tokenString, 'text/plain');
$tokenProcessor->addRow(['membershipId' => $this->getMembershipID()]);
$tokenProcessor->evaluate();
}
/**
- * Get declared membership tokens.
+ * Get declared participant tokens.
*
* @return string[]
*/
'{participant.participant_registered_by_id}' => 'Registered By Participant ID',
'{participant.transferred_to_contact_id}' => 'Transferred to Contact ID',
'{participant.participant_role}' => 'Participant Role (label)',
- '{participant.event_title}' => 'Event Title',
- '{participant.event_start_date}' => 'Event Start Date',
- '{participant.event_end_date}' => 'Event End Date',
'{participant.fee_label}' => 'Fee Label',
'{participant.default_role_id}' => 'Default Role',
'{participant.template_title}' => 'Event Template Title',
- '{participant.currency}' => 'Currency',
- '{participant.participant_note}' => 'Participant Note',
'{participant.' . $this->getCustomFieldName('text') . '}' => 'Enter text here :: Group with field text',
];
}
+ /**
+ * Test that domain tokens are consistently rendered.
+ */
+ public function testDomainTokenConsistency(): void {
+ $tokens = CRM_Core_SelectValues::domainTokens();
+ $this->assertEquals($this->getDomainTokens(), $tokens);
+ $tokenProcessor = new TokenProcessor(\Civi::dispatcher(), [
+ 'controller' => __CLASS__,
+ 'smarty' => FALSE,
+ ]);
+ $tokens['{domain.id}'] = 'Domain ID';
+ $tokens['{domain.description}'] = 'Domain Description';
+ $this->assertEquals($tokens, $tokenProcessor->listTokens());
+ }
+
+ /**
+ * Get declared participant tokens.
+ *
+ * @return string[]
+ */
+ public function getDomainTokens(): array {
+ return [
+ '{domain.name}' => ts('Domain name'),
+ '{domain.address}' => ts('Domain (organization) address'),
+ '{domain.phone}' => ts('Domain (organization) phone'),
+ '{domain.email}' => 'Domain (organization) email',
+ '{domain.id}' => ts('Domain ID'),
+ '{domain.description}' => ts('Domain Description'),
+ ];
+ }
+
+ /**
+ * Test that domain tokens are consistently rendered.
+ */
+ public function testEventTokenConsistency(): void {
+ $tokens = CRM_Core_SelectValues::eventTokens();
+ $this->assertEquals($this->getEventTokens(), $tokens);
+ $tokenProcessor = new TokenProcessor(\Civi::dispatcher(), [
+ 'controller' => __CLASS__,
+ 'smarty' => FALSE,
+ 'schema' => ['eventId'],
+ ]);
+ $this->assertEquals(array_merge($tokens, $this->getDomainTokens()), $tokenProcessor->listTokens());
+ }
+
+ /**
+ * Get expected event tokens.
+ *
+ * @return string[]
+ */
+ protected function getEventTokens(): array {
+ return [
+ '{event.event_id}' => 'Event ID',
+ '{event.title}' => 'Event Title',
+ '{event.start_date}' => 'Event Start Date',
+ '{event.end_date}' => 'Event End Date',
+ '{event.event_type}' => 'Event Type',
+ '{event.summary}' => 'Event Summary',
+ '{event.contact_email}' => 'Event Contact Email',
+ '{event.contact_phone}' => 'Event Contact Phone',
+ '{event.description}' => 'Event Description',
+ '{event.location}' => 'Event Location',
+ '{event.fee_amount}' => 'Event Fee',
+ '{event.info_url}' => 'Event Info URL',
+ '{event.registration_url}' => 'Event Registration URL',
+ '{event.balance}' => 'Event Balance',
+ ];
+ }
+
}