function MessageViewBuilder::view
Same name in other branches
- 9 core/modules/contact/src/MessageViewBuilder.php \Drupal\contact\MessageViewBuilder::view()
- 10 core/modules/contact/src/MessageViewBuilder.php \Drupal\contact\MessageViewBuilder::view()
- 11.x core/modules/contact/src/MessageViewBuilder.php \Drupal\contact\MessageViewBuilder::view()
Overrides EntityViewBuilder::view
File
-
core/
modules/ contact/ src/ MessageViewBuilder.php, line 28
Class
- MessageViewBuilder
- Render controller for contact messages.
Namespace
Drupal\contactCode
public function view(EntityInterface $entity, $view_mode = 'full', $langcode = NULL) {
$build = parent::view($entity, $view_mode, $langcode);
if ($view_mode == 'mail') {
// Convert field labels into headings.
// @todo Improve \Drupal\Core\Mail\MailFormatHelper::htmlToText() to
// convert DIVs correctly.
foreach (Element::children($build) as $key) {
if (isset($build[$key]['#label_display']) && $build[$key]['#label_display'] == 'above') {
$build[$key] += [
'#prefix' => '',
];
$build[$key]['#prefix'] = $build[$key]['#title'] . ":\n";
$build[$key]['#label_display'] = 'hidden';
}
}
}
return $build;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.