You are here

function relation_create in Relation 7

Constructs a relation from a machine name and a list of endpoints.

Parameters

$relation_type: The relation type (bundle) of the relation to be created.

$endpoints: A list of endpoint entities. Each endpoint is defined by an associate array, with an entity_type and entity_id key. For example:


  array(
    array('entity_type' => 'node', 'entity_id' => 1),
    array('entity_type' => 'user', 'entity_id' => 5),
  array);
  

Return value

The new relation object.

9 calls to relation_create()
RelationAPITestCase::testRelationRevision in tests/relation.test
Tests relation revisions.
RelationAPITestCase::testRelationSave in tests/relation.test
Tests saving of relations.
RelationFeedsProcessor::newEntity in relation_feeds/RelationFeedsProcessor.inc
RelationTestCase::saveRelation in tests/relation.test
Saves a relation.
RelationUITestCase::testRelationImport in tests/relation_ui.test
Tests importing method.

... See full list

File

./relation.module, line 594
Describes relations between entities.

Code

function relation_create($type, $endpoints, $account = NULL) {
  if (!isset($account)) {
    $account = $GLOBALS['user'];
  }
  $relation = new stdClass();
  $relation->is_new = TRUE;
  $relation->relation_type = $type;
  $relation->uid = $account->uid;
  $relation->endpoints[LANGUAGE_NONE] = $endpoints;
  return $relation;
}