public function WebformMessageManager::build in Webform 8.5
Same name and namespace in other branches
- 6.x src/WebformMessageManager.php \Drupal\webform\WebformMessageManager::build()
Build message.
Return value
array A render array containing a message.
Overrides WebformMessageManagerInterface::build
3 calls to WebformMessageManager::build()
- WebformMessageManager::append in src/
WebformMessageManager.php - Append inline message message to a render array.
- WebformMessageManager::display in src/
WebformMessageManager.php - Display message.
- WebformMessageManager::render in src/
WebformMessageManager.php - Render message.
File
- src/
WebformMessageManager.php, line 204
Class
- WebformMessageManager
- Defines the webform message (and login) manager.
Namespace
Drupal\webformCode
public function build($key) {
if ($message = $this
->get($key)) {
// Make sure $message is renderable array.
if (!is_array($message)) {
$message = [
'#markup' => $message,
'#allowed_tags' => Xss::getAdminTagList(),
];
}
// Set max-age to 0 if settings message contains any [token] values.
$setting_message = $this
->getSetting($key);
if ($setting_message && strpos($setting_message, '[') !== FALSE) {
$message['#cache']['max-age'] = 0;
}
return $message;
}
else {
return [];
}
}