protected function MailEntity::build in Simplenews 3.x
Same name and namespace in other branches
- 8.2 src/Mail/MailEntity.php \Drupal\simplenews\Mail\MailEntity::build()
- 8 src/Mail/MailEntity.php \Drupal\simplenews\Mail\MailEntity::build()
Build the entity object.
The resulting build array is cached as it is used in multiple places.
Parameters
string|null $format: (Optional) Override the default format. Defaults to getFormat().
2 calls to MailEntity::build()
- MailEntity::buildBody in src/
Mail/ MailEntity.php - Build the themed newsletter body.
- MailEntity::getAttachments in src/
Mail/ MailEntity.php - Returns an array of attachments for this newsletter mail.
File
- src/
Mail/ MailEntity.php, line 284
Class
- MailEntity
- Default mail class for entities.
Namespace
Drupal\simplenews\MailCode
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'.
$build = \Drupal::entityTypeManager()
->getViewBuilder($this
->getIssue()
->getEntityTypeId())
->view($this
->getIssue(), 'email_' . $format, $this
->getLanguage());
$build['#entity_type'] = $this
->getIssue()
->getEntityTypeId();
// @todo: Consider using render caching.
unset($build['#cache']);
// 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
->getIssue()
->getEntityTypeId()) {
unset($build['#theme']);
}
$this->build[$format] = $build;
return $this->build[$format];
}