You are here

public static function FieldHelper::getFieldEntities in Helper 7

File

lib/FieldHelper.php, line 164

Class

FieldHelper

Code

public static function getFieldEntities($entity_type, $entity, $field_name, $column = NULL) {
  $columns = static::getEntityReferencingFieldColumns($field_name);
  if (!isset($column)) {
    reset($columns);
    $column = key($columns);
  }
  if (isset($columns[$column])) {
    if ($ids = static::getValues($entity_type, $entity, $field_name, $column)) {
      $entities = entity_load($columns[$column], $ids);
      return array_filter(ArrayHelper::transformAssociativeValues($ids, $entities));
    }
  }
  return array();
}