You are here

function relation_entity_collector_store in Relation 7

Page callback copying a relation into SESSION.

1 string reference to 'relation_entity_collector_store'
relation_entity_collector_menu in relation_entity_collector/relation_entity_collector.module
Implements hook_menu().

File

relation_entity_collector/relation_entity_collector.module, line 60
Relation Entity Collector Block.

Code

function relation_entity_collector_store($relation) {
  $_SESSION['relation_edit'] = $relation;
  $_SESSION['relation_type'] = $relation->relation_type;
  $_SESSION['relation_entity_keys'] = array();
  foreach ($relation->endpoints[LANGUAGE_NONE] as $delta => $endpoint) {
    $entities = entity_load($endpoint['entity_type'], array(
      $endpoint['entity_id'],
    ));
    $entity = $entities[$endpoint['entity_id']];
    list(, , $entity_bundle) = entity_extract_ids($endpoint['entity_type'], $entity);
    $_SESSION['relation_entity_keys'][] = array(
      'entity_type' => $endpoint['entity_type'],
      'entity_id' => $endpoint['entity_id'],
      'entity_bundle' => $entity_bundle,
      'r_index' => $delta,
      'entity_label' => "{$entity_bundle}: " . entity_label($endpoint['entity_type'], $entity),
      'entity_key' => $endpoint['entity_type'] . ':' . $endpoint['entity_id'],
    );
  }
  drupal_set_message(t('The relation is ready for edit'));
  drupal_goto();
}