You are here

function party_attached_entity_from_party_context in Party 7

Same name and namespace in other branches
  1. 8.2 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
  $entity = $context->data
    ->getDataSetController($conf['data_set_name'])
    ->getEntity();
  if ($entity) {
    return ctools_context_create('entity:' . $entity_type, $entity);
  }
}