You are here

public function Registration::buildContent in Entity Registration 7.2

Same name and namespace in other branches
  1. 8.2 lib/registration.entity.inc \Registration::buildContent()
  2. 7 lib/registration.entity.inc \Registration::buildContent()

Build content for Registration.

Return value

array Render array for a registration entity.

Overrides Entity::buildContent

File

lib/registration.entity.inc, line 47
Entity hooks and callbacks for registrations.

Class

Registration
Main class for Registration entities.

Code

public function buildContent($view_mode = 'full', $langcode = NULL) {
  $build = parent::buildContent($view_mode, $langcode);
  $wrapper = entity_metadata_wrapper('registration', $this);
  $host_entity_type_info = entity_get_info($this->entity_type);
  $host_entity = $wrapper->entity
    ->value();
  $state = $wrapper->state
    ->value();
  $author = $wrapper->author
    ->value();
  $registrant_type = $wrapper->registrant
    ->type();
  $registrant = $wrapper->registrant
    ->value();
  list(, , $host_entity_bundle) = entity_extract_ids($this->entity_type, $host_entity);
  $host_label = entity_label($this->entity_type, $host_entity);
  $host_uri = $host_entity ? entity_uri($this->entity_type, $host_entity) : NULL;
  $build['mail'] = array(
    '#theme' => 'registration_property_field',
    '#label' => t('Email Address'),
    '#items' => array(
      array(
        '#markup' => $wrapper->registrant_mail
          ->value(),
      ),
    ),
    '#classes' => 'field field-label-inline clearfix',
  );

  // Link to host entity.
  $host_entity_link_label = isset($host_entity_type_info['bundles'][$host_entity_bundle]['label']) ? '<div class="field-label">' . $host_entity_type_info['bundles'][$host_entity_bundle]['label'] . '</div>' : '';
  $build['host_entity_link'] = array(
    '#theme' => 'registration_property_field',
    '#label' => $host_entity_link_label,
    '#items' => array(
      array(
        '#markup' => l($host_label, $host_uri['path']),
      ),
    ),
    '#classes' => 'field field-label-inline clearfix',
  );
  $build['created'] = array(
    '#theme' => 'registration_property_field',
    '#label' => t('Created'),
    '#items' => array(
      array(
        '#markup' => format_date($this->created),
      ),
    ),
    '#classes' => 'field field-label-inline clearfix',
  );
  $build['updated'] = array(
    '#theme' => 'registration_property_field',
    '#label' => t('Updated'),
    '#items' => array(
      array(
        '#markup' => format_date($this->updated),
      ),
    ),
    '#classes' => 'field field-label-inline clearfix',
  );
  $build['spaces'] = array(
    '#theme' => 'registration_property_field',
    '#label' => t('Slots Used'),
    '#items' => array(
      array(
        '#markup' => $this->count,
      ),
    ),
    '#classes' => 'field field-label-inline clearfix',
  );
  if ($author) {
    $build['author'] = array(
      '#theme' => 'registration_property_field',
      '#label' => t('Author'),
      '#items' => array(
        array(
          '#markup' => theme('username', array(
            'account' => $author,
          )),
        ),
      ),
      '#classes' => 'field field-label-inline clearfix',
      '#attributes' => '',
    );
  }
  $build['registrant'] = array(
    '#theme' => 'registration_property_field',
    '#label' => t('Registrant'),
    '#items' => array(
      array(
        '#markup' => theme('registration_registrant_link', array(
          'registrant_type' => $registrant_type,
          'registrant' => $registrant,
        )),
      ),
    ),
    '#classes' => 'field field-label-inline clearfix',
    '#attributes' => '',
  );
  $build['state'] = array(
    '#theme' => 'registration_property_field',
    '#label' => t('State'),
    '#items' => array(
      array(
        '#markup' => $state ? filter_xss_admin(entity_label('registration_state', $state)) : '',
      ),
    ),
    '#classes' => 'field field-label-inline clearfix',
  );
  return $build;
}