Skip to content

Instantly share code, notes, and snippets.

@webflo
Last active November 18, 2015 16:15
Show Gist options
  • Save webflo/9f6adca58f80921df726 to your computer and use it in GitHub Desktop.
Save webflo/9f6adca58f80921df726 to your computer and use it in GitHub Desktop.
/**
* Implements hook_entity_type_alter().
* @param \Drupal\Core\Entity\EntityTypeInterface[] $entity_types
*/
function example_contact_form_entity_type_alter(array &$entity_types) {
$entity_types['contact_message']->setViewBuilderClass('Drupal\example_contact_form\ContactMessageViewBuilder');
}
---
class ContactMessageViewBuilder extends MessageViewBuilder {
}
---
/**
* Implements hook_mail_alter().
*/
function example_contact_form_mail_alter(&$message) {
if ($message['module'] == 'contact' && isset($message['params']['contact_message'])) {
$message['headers']['Content-Type'] = 'text/html';
$render = entity_view($message['params']['contact_message'], 'mail');
$message['body'] = array(
render($render),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment