public function ContactEmail::getFormat in Contact Emails 8
Get the email body format.
Parameters
\Drupal\contact\MessageInterface $message: The contact message.
Return value
string The email body format.
Overrides ContactEmailInterface::getFormat
1 call to ContactEmail::getFormat()
- ContactEmail::getBody in src/Entity/ ContactEmail.php 
- Get the email body.
File
- src/Entity/ ContactEmail.php, line 347 
Class
- ContactEmail
- Defines the Contact Email entity.
Namespace
Drupal\contact_emails\EntityCode
public function getFormat(MessageInterface $message) {
  $body = $this
    ->get('message');
  // If body is empty, there is nothing to check.
  if ($body
    ->isEmpty()) {
    return 'text/plain; charset=UTF-8; format=flowed; delsp=yes';
  }
  // Default to html.
  $format = 'text/html';
  // Get selected format.
  if (!empty($body->format) && ($filter_format = FilterFormat::load($body->format))) {
    // If the selected format does not allow html, set the email as plain
    // text.
    $restrictions = $filter_format
      ->getHtmlRestrictions();
    if ($restrictions && !$restrictions['allowed']) {
      $format = 'text/plain; charset=UTF-8; format=flowed; delsp=yes';
    }
  }
  return $format;
}