You are here

protected function SimplenewsSourceEntity::getBodyWithFormat in Simplenews 7.2

Get the body with the requested format.

Parameters

$format: Either html or plain.

Return value

The rendered mail body as a string.

2 calls to SimplenewsSourceEntity::getBodyWithFormat()
SimplenewsSourceEntity::getBody in includes/simplenews.source.inc
Implements SimplenewsSourceInterface::getBody().
SimplenewsSourceEntity::getPlainBody in includes/simplenews.source.inc
Implements SimplenewsSourceInterface::getBody().

File

includes/simplenews.source.inc, line 706
Contains SimplenewsSource interface and implementations.

Class

SimplenewsSourceEntity
Default source class for entities.

Code

protected function getBodyWithFormat($format) {

  // Switch to correct user and language context.
  $this
    ->setContext();
  if ($cache = $this->cache
    ->get('final', 'body:' . $format)) {
    return $cache;
  }
  $body = $this
    ->buildBody($format);

  // Build message body, replace tokens.
  $body = token_replace($body, $this
    ->getTokenContext(), array(
    'sanitize' => FALSE,
  ));
  if ($format == 'plain') {

    // Convert HTML to text if requested to do so.
    $body = simplenews_html_to_text($body, $this
      ->getNewsletter()->hyperlinks);
  }
  $this->cache
    ->set('final', 'body:' . $format, $body);
  $this
    ->resetContext();
  return $body;
}