private function WebformCivicrmPreProcess::showNotYouMessage in Webform CiviCRM Integration 8.5
Displays the admin-defined message with "not you?" link to known contacts
Parameters
string $message: Raw message with tokens
array $contact: CiviCRM contact array
1 call to WebformCivicrmPreProcess::showNotYouMessage()
- WebformCivicrmPreProcess::alterForm in src/
WebformCivicrmPreProcess.php - Alter front-end of webforms: Called by hook_form_alter() when rendering a civicrm-enabled webform Add custom prefix. Display messages. Block users who should not have access. Set webform default values.
File
- src/
WebformCivicrmPreProcess.php, line 847 - Front-end form pre-processor.
Class
Namespace
Drupal\webform_civicrmCode
private function showNotYouMessage($message, $contact) {
$request = \Drupal::request();
$message = $this
->replaceTokens($message, $contact);
preg_match_all('#\\{([^}]+)\\}#', $message, $matches);
if (!empty($matches[0])) {
$q = $request->query
->all();
unset($q['cs'], $q['cid'], $q['cid1']);
if (empty($request->query
->get('cid')) && empty($request->query
->get('cid1'))) {
$q['cid1'] = 0;
}
foreach ($matches[0] as $pos => $match) {
$link = Link::createFromRoute($matches[1][$pos], '<current>', [], [
'query' => $q,
])
->toString();
$message = str_replace($match, $link, $message);
}
}
$this
->setMessage(Markup::create($message));
}