You are here

public function PartyDefaultDataSet::loadEntities in Party 7

Same name and namespace in other branches
  1. 8.2 includes/party.data.inc \PartyDefaultDataSet::loadEntities()

Load the full entities.

Parameters

array|null $deltas: (optional) An array of delta(s) to load or NULL to load all entities.

Return value

$this

2 calls to PartyDefaultDataSet::loadEntities()
PartyDefaultDataSet::getEntities in includes/party.data.inc
Get all attached entities
PartyDefaultDataSet::getEntity in includes/party.data.inc
Get a particular attached entity

File

includes/party.data.inc, line 357
Provides the default class for managing party - Attached entity relationships.

Class

PartyDefaultDataSet
Class PartyDefaultDataSet

Code

public function loadEntities($deltas = NULL) {

  // Get our array of deltas
  if ($deltas === NULL) {

    // Load all entities
    $deltas = array_keys($this->entities);
  }

  // Iterate over our deltas loading our entities if required.
  foreach ($deltas as $delta) {
    if (isset($this->entities[$delta]) && isset($this->entities[$delta]->is_stub)) {

      // This entity is a stub so needs loading. First get the entity id from
      // stub entity.
      $entity_id = $this->entities[$delta]->{$this
        ->getDataInfo('id key')};
      $entities_loaded = entity_load($this
        ->getDataInfo('entity type'), array(
        $entity_id,
      ));
      $this->entities[$delta] = reset($entities_loaded);

      // If we couldn't load the entity, detach it.
      if (!$this->entities[$delta]) {
        $this
          ->detachEntityByDelta($delta);
      }
      else {
        $this->entities[$delta]->data_set_name = $this->data_set;
        $this->entities[$delta]->party_attaching_party = $this->party->pid;
      }
    }
  }
  return $this;
}