if (!Civi::cache('metadata')->has($cacheKey)) {
$event = Event::get($this->checkPermissions)->addWhere('id', '=', $eventID)
->setSelect(array_merge([
- 'loc_block_id.address_id.name',
- 'loc_block_id.address_id.street_address',
- 'loc_block_id.address_id.supplemental_address_1',
- 'loc_block_id.address_id.supplemental_address_2',
- 'loc_block_id.address_id.supplemental_address_3',
- 'loc_block_id.address_id.city',
+ 'loc_block_id.address_id.*',
'loc_block_id.address_id.state_province_id:label',
- 'loc_block_id.address_id.postal_code',
+ 'loc_block_id.address_id.country_id:label',
'loc_block_id.email_id.email',
'loc_block_id.email_2_id.email',
'loc_block_id.phone_id.phone',
'custom.*',
], $this->getExposedFields()))
->execute()->first();
- $tokens['location']['text/plain'] = \CRM_Utils_Address::format([
+ $addressValues = [
'address_name' => $event['loc_block_id.address_id.name'],
- 'street_address' => $event['loc_block_id.address_id.street_address'],
- 'supplemental_address_1' => $event['loc_block_id.address_id.supplemental_address_1'],
- 'supplemental_address_2' => $event['loc_block_id.address_id.supplemental_address_2'],
- 'supplemental_address_3' => $event['loc_block_id.address_id.supplemental_address_3'],
- 'city' => $event['loc_block_id.address_id.city'],
'state_province' => $event['loc_block_id.address_id.state_province_id:label'],
- 'postal_code' => $event['loc_block_id.address_id.postal_code'],
- ]);
+ 'country' => $event['loc_block_id.address_id.country_id:label'],
+ ];
+ foreach ($event as $key => $value) {
+ if (strpos($key, 'loc_block_id.address_id.') === 0) {
+ $addressValues[str_replace('loc_block_id.address_id.', '', $key)] = $value;
+ }
+ }
+ $tokens['location']['text/plain'] = \CRM_Utils_Address::format($addressValues);
$tokens['info_url']['text/html'] = \CRM_Utils_System::url('civicrm/event/info', 'reset=1&id=' . $eventID, TRUE, NULL, FALSE, TRUE);
$tokens['registration_url']['text/html'] = \CRM_Utils_System::url('civicrm/event/register', 'reset=1&id=' . $eventID, TRUE, NULL, FALSE, TRUE);
$tokens['start_date']['text/html'] = !empty($event['start_date']) ? new DateTime($event['start_date']) : '';
// WORKAROUND: CRM_Event_Tokens copies `civicrm_event` data into metadata cache. That should probably change, but that's a different scope-of-work.
// `clear()` works around it. This should be removed if that's updated, but it will be safe either way.
Civi::cache('metadata')->clear();
-
+ $this->revertSetting('mailing_format');
parent::tearDown();
}
event.description :event description
event.location :15 Walton St<br />
up the road<br />
-Emerald City, Maine 90210<br />
+Emerald City, Maine 90210-1234<br />
+United States<br />
event.info_url :' . CRM_Utils_System::url('civicrm/event/info', NULL, TRUE) . '&reset=1&id=1
event.registration_url :' . CRM_Utils_System::url('civicrm/event/register', NULL, TRUE) . '&reset=1&id=1
event.pay_later_receipt :Please transfer funds to our bank account.
'city' => 'Emerald City',
'state_province_id:label' => 'Maine',
'postal_code' => 90210,
+ 'postal_code_suffix' => 1234,
])->execute()->first()['id'];
+ \Civi::settings()->set('mailing_format', '{contact.street_address}{ }{contact.supplemental_address_1}{ }{contact.supplemental_address_2}{ }{contact.city}{ }{contact.state_province}{ }{contact.postal_code}');
$phoneID = Phone::create()
->setValues(['phone' => '456 789'])
->execute()
protected $tempDirs;
/**
- * @var CRM_Core_Transaction|null
+ * @var CRM_Core_Transaction
*/
- private $tx = NULL;
+ private $tx;
+
+ /**
+ * @var array
+ */
+ protected $originalSettings = [];
/**
* Array of IDs created to support the test.
$this->renameLabels();
$this->ensureMySQLMode(['IGNORE_SPACE', 'ERROR_FOR_DIVISION_BY_ZERO', 'STRICT_TRANS_TABLES']);
putenv('CIVICRM_SMARTY_DEFAULT_ESCAPE=1');
+ $this->originalSettings = \Civi::settings()->all();
}
/**
parent::tearDown();
}
+ /**
+ * @param string $setting
+ */
+ protected function revertSetting(string $setting): void {
+ \Civi::settings()->set($setting, $this->originalSettings[$setting]);
+ }
+
/**
* CHeck that all tests that have created payments have created them with the right financial entities.
*