You are here

public function SimplemetaEntity::buildContent in Simple Meta 7.2

Builds a structured array representing the entity's content.

Overrides Entity::buildContent

See also

entity_build_content()

File

./simplemeta.info.inc, line 71
Entity API integration, classes, controllers, etc.

Class

SimplemetaEntity
Class SimplemetaEntity.

Code

public function buildContent($view_mode = 'full', $langcode = NULL) {
  $data = $this->data;
  $content = array();
  if ($view_mode == 'meta') {
    foreach ($data as $key => $value) {
      if ($key == 'title') {
        $content[$key] = array(
          '#markup' => check_plain($value),
        );
      }
      $content[$key]['#attached']['drupal_add_html_head'][] = array(
        array(
          '#theme' => 'html_tag',
          '#tag' => 'meta',
          '#attributes' => array(
            'name' => $key,
            'content' => $value,
          ),
        ),
        'simplemeta_' . $key,
      );
    }
  }
  else {
    foreach ($data as $key => $value) {
      $content[$key] = array(
        '#markup' => check_plain($value),
      );
    }
  }
  return entity_get_controller($this->entityType)
    ->buildContent($this, $view_mode, $langcode, $content);
}