You are here

class NodeRegistrationEntityClass in Node registration 7

Entity class for Node Registrations

Hierarchy

Expanded class hierarchy of NodeRegistrationEntityClass

2 string references to 'NodeRegistrationEntityClass'
node_registration_entity_info in includes/node_registration.entity.inc
Implements hook_entity_info().
_nr_webform_fields_event_node in submodules/nr_webform_fields/nr_webform_fields.module
Callback for webform_fields to find the event node from a NodeRegistrationEntityClass entity.

File

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

View source
class NodeRegistrationEntityClass extends Entity {
  public $nid;
  public $node;
  public $is_new = 0;
  public $registration_id = 0;
  public $language = LANGUAGE_NONE;
  public $slots = 1;
  public $attended = 0;
  public $verified = 0;
  public $cancelled = 0;
  public $waitinglist = 0;

  /**
   * Override buildContent() to add registration properties.
   */
  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,
    );
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Entity::$defaultLabel protected property 1
Entity::$entityInfo protected property
Entity::$entityType protected property
Entity::$idKey protected property
Entity::$wrapper protected property
Entity::bundle public function Returns the bundle of the entity. Overrides EntityInterface::bundle
Entity::defaultLabel protected function Defines the entity label if the 'entity_class_label' callback is used. 1
Entity::defaultUri protected function Override this in order to implement a custom default URI and specify 'entity_class_uri' as 'uri callback' hook_entity_info().
Entity::delete public function Permanently deletes the entity. Overrides EntityInterface::delete
Entity::entityInfo public function Returns the info of the type of the entity. Overrides EntityInterface::entityInfo
Entity::entityType public function Returns the type of the entity. Overrides EntityInterface::entityType
Entity::export public function Exports the entity. Overrides EntityInterface::export
Entity::getTranslation public function Gets the raw, translated value of a property or field. Overrides EntityInterface::getTranslation
Entity::hasStatus public function Checks if the entity has a certain exportable status. Overrides EntityInterface::hasStatus
Entity::identifier public function Returns the entity identifier, i.e. the entities name or numeric id. Overrides EntityInterface::identifier
Entity::internalIdentifier public function Returns the internal, numeric identifier. Overrides EntityInterface::internalIdentifier
Entity::isDefaultRevision public function Checks whether the entity is the default revision. Overrides EntityInterface::isDefaultRevision
Entity::label public function Returns the label of the entity. Overrides EntityInterface::label
Entity::save public function Permanently saves the entity. Overrides EntityInterface::save
Entity::setUp protected function Set up the object instance on construction or unserializiation.
Entity::uri public function Returns the uri of the entity just as entity_uri(). Overrides EntityInterface::uri
Entity::view public function Generate an array for rendering the entity. Overrides EntityInterface::view
Entity::wrapper public function Returns the EntityMetadataWrapper of the entity. Overrides EntityInterface::wrapper
Entity::__construct public function 1
Entity::__sleep public function Magic method to only serialize what's necessary.
Entity::__wakeup public function Magic method to invoke setUp() on unserialization.
NodeRegistrationEntityClass::$attended public property
NodeRegistrationEntityClass::$cancelled public property
NodeRegistrationEntityClass::$is_new public property
NodeRegistrationEntityClass::$language public property
NodeRegistrationEntityClass::$nid public property
NodeRegistrationEntityClass::$node public property
NodeRegistrationEntityClass::$registration_id public property
NodeRegistrationEntityClass::$slots public property
NodeRegistrationEntityClass::$verified public property
NodeRegistrationEntityClass::$waitinglist public property
NodeRegistrationEntityClass::buildContent public function Override buildContent() to add registration properties. Overrides Entity::buildContent