function relation_rules_set_endpoints in Relation 7
Same name and namespace in other branches
- 8.2 relation.rules.inc \relation_rules_set_endpoints()
- 8 relation.rules.inc \relation_rules_set_endpoints()
Endpoint property setter callback.
Parameters
$data: The relation object that we are going to modify.
$name: Name of the provided Rules variable.
$endpoint_wrappers: Array of entity wrappers that we are going to add to the relation object.
1 string reference to 'relation_rules_set_endpoints'
- relation_entity_property_info in ./
relation.module - Implements hook_entity_property_info().
File
- ./
relation.rules.inc, line 146 - Implements the Rules module API for Relation.
Code
function relation_rules_set_endpoints(&$relation = NULL, $name = NULL, $entity_wrappers = NULL) {
// Check that we are creating a new relation. Updating existing relations
// aren't supported.
if (isset($relation->rid) || empty($entity_wrappers)) {
return;
}
foreach ($entity_wrappers as $i => $entity_wrapper) {
$entity = $entity_wrapper
->value();
$entity_type = $entity_wrapper
->type();
$id_key = $entity_wrapper
->entityKey('id');
$bundle_key = $entity_wrapper
->entityKey('bundle');
if (isset($entity->{$id_key})) {
$relation->endpoints[LANGUAGE_NONE][$i] = array(
'entity_type' => $entity_wrapper
->type(),
'entity_id' => $entity->{$id_key},
'entity_bundle' => isset($entity->{$bundle_key}) ? $entity->{$bundle_key} : $entity_type,
'r_index' => $i,
);
}
}
}