function entityreference_current_get_current_entity in Entityreference Current 7
Get values for prepopulating fields via Object.
Parameters
$field: The field info array.
$instance: The instance info array.
See also
entityreference_current_get_values()
1 call to entityreference_current_get_current_entity()
- entityreference_current_get_values in ./
entityreference_current.inc - Wrapper function to get context (e.g. from Menu Object or OG-context).
File
- ./
entityreference_current.inc, line 123 - Common non-hook functions for Entity Reference Current module.
Code
function entityreference_current_get_current_entity($field, $instance) {
$target_type = $field['settings']['target_type'];
$entity = menu_get_object($target_type);
if (empty($entity) && !empty($instance['settings']['behaviors']['current']['use_uid']) && $target_type == 'user') {
// If target is user check to see if we can get uid from entity(only for nodes)
$entity = menu_get_object();
if (!empty($entity->uid)) {
$entity = user_load($entity->uid);
}
}
return $entity;
}