You are here

public function NodeRegistrationEntityClass::buildContent in Node registration 7

Override buildContent() to add registration properties.

Overrides Entity::buildContent

File

includes/node_registration.entity.inc, line 238
Entity hooks and callbacks for registrations.

Class

NodeRegistrationEntityClass
Entity class for Node Registrations

Code

public function buildContent($view_mode = 'full', $langcode = NULL) {
  $node = $this->node ?: node_load($this->nid);

  // Extra fields need this... @see _field_extra_fields_pre_render().
  $content = array(
    '#view_mode' => $view_mode,
  );

  // Cancel link.
  $uri = node_registration_uri($this);
  _node_registration_fake_field($content, 'cancel_link', t('Cancel'), array(
    '#type' => 'link',
    '#title' => t('Cancel registration'),
    '#href' => $uri['path'] . '/cancel',
    '#access' => node_registration_access($this, 'cancel'),
  ), FALSE);

  // Event node.
  $uri = node_uri($node);
  _node_registration_fake_field($content, 'event_node', t('Event node'), array(
    '#type' => 'link',
    '#title' => $node->title,
    '#href' => $uri['path'],
    '#access' => node_access('view', $node),
  ));

  // Rendered event node.
  $node_build = node_view($node, 'teaser');
  _node_registration_fake_field($content, 'event_node_content', t('Event node'), $node_build, FALSE);

  // Author.
  $author = user_load($this->author_uid ?: 0);
  _node_registration_fake_field($content, 'author', t('Author'), array(
    '#theme' => 'username',
    '#account' => $author,
  ));

  // Account.
  $account = user_load($this->uid ?: 0);
  _node_registration_fake_field($content, 'account', t('Registree'), array(
    '#theme' => 'username',
    '#account' => $account,
  ));

  // E-mail address.
  _node_registration_fake_field($content, 'email', t('E-mail address'), array(
    '#markup' => $this->email,
  ));

  // Slots.
  _node_registration_fake_field($content, 'slots', t('Slots'), array(
    '#markup' => $this->slots,
  ));

  // Attended.
  _node_registration_fake_field($content, 'attended', t('Attended'), array(
    '#markup' => $this->attended ? t('Yes') : t('No'),
  ));
  $content = entity_get_controller('node_registration')
    ->buildContent($this, $view_mode, $langcode, $content);
  return array(
    '#theme' => 'node_registration',
    '#registration' => $this,
    '#content' => $content,
    '#node' => $node,
  );
}