Last active
November 18, 2015 16:15
-
-
Save webflo/9f6adca58f80921df726 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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