protected function SimplenewsSourceEntity::build in Simplenews 7.2
Build the entity object.
The resulting build array is cached as it is used in multiple places.
Parameters
$format: (Optional) Override the default format. Defaults to getFormat().
3 calls to SimplenewsSourceEntity::build()
- SimplenewsSourceEntity::buildBody in includes/
simplenews.source.inc - Build the themed newsletter body.
- SimplenewsSourceEntity::buildFooter in includes/
simplenews.source.inc - Builds the themed footer.
- SimplenewsSourceEntity::getAttachments in includes/
simplenews.source.inc - Implements SimplenewsSourceInterface::getAttachments().
File
- includes/
simplenews.source.inc, line 634 - Contains SimplenewsSource interface and implementations.
Class
- SimplenewsSourceEntity
- Default source class for entities.
Code
protected function build($format = NULL) {
if (empty($format)) {
$format = $this
->getFormat();
}
if (!empty($this->build[$format])) {
return $this->build[$format];
}
// Build message body
// Supported view modes: 'email_plain', 'email_html', 'email_textalt'
$build = entity_view($this
->getEntityType(), array(
$this
->getEntity(),
), 'email_' . $format);
$build = reset($build[$this
->getEntityType()]);
// We need to prevent the standard theming hooks, but we do want to allow
// modules such as panelizer that override it, so only clear the standard
// entity hook and entity type hooks.
if ($build['#theme'] == 'entity' || $build['#theme'] == $this
->getEntityType()) {
unset($build['#theme']);
}
list(, , $bundle) = entity_extract_ids($this
->getEntityType(), $this
->getEntity());
foreach (field_info_instances($this
->getEntityType(), $bundle) as $field_name => $field) {
if (isset($build[$field_name])) {
$build[$field_name]['#theme'] = 'simplenews_field';
}
}
$this->build[$format] = $build;
return $this->build[$format];
}