You are here

function party_attached_entity_from_party_context in Party 8.2

Same name and namespace in other branches
  1. 7 plugins/relationships/attached_entity_from_party.inc \party_attached_entity_from_party_context()

Return a new context based on an existing context.

1 string reference to 'party_attached_entity_from_party_context'
attached_entity_from_party.inc in plugins/relationships/attached_entity_from_party.inc
Plugin to provide an relationship handler for term from node.

File

plugins/relationships/attached_entity_from_party.inc, line 25
Plugin to provide an relationship handler for term from node.

Code

function party_attached_entity_from_party_context($context, $conf) {
  $data_set = party_get_data_set_info($conf['data_set_name']);
  $entity_type = $data_set['entity type'];

  // If unset it wants a generic, unfilled context, which is just NULL.
  if (empty($context->data)) {
    return ctools_context_create_empty('entity:' . $entity_type, NULL);
  }

  // Load attached entity from party ID
  // @todo: Do this without loading all the entities? For performance?
  $attached_entities = party_get_attached_entities($context->data, $conf['data_set_name']);
  $attached_entity = array_shift($attached_entities);
  if ($attached_entity !== NULL) {
    return ctools_context_create('entity:' . $entity_type, $attached_entity);
  }
}