You are here

function lingotek_get_fc_parent in Lingotek Translation 7.7

Same name and namespace in other branches
  1. 7.4 lingotek.module \lingotek_get_fc_parent()
  2. 7.5 lingotek.module \lingotek_get_fc_parent()
  3. 7.6 lingotek.module \lingotek_get_fc_parent()
1 call to lingotek_get_fc_parent()
lingotek_get_host_language in ./lingotek.module

File

./lingotek.module, line 2202

Code

function lingotek_get_fc_parent($entity) {
  $query = new EntityFieldQuery();
  $query
    ->fieldCondition($entity
    ->fieldInfo(), 'revision_id', $entity->revision_id);
  if (!$entity
    ->isInUse()) {
    $query
      ->age(FIELD_LOAD_REVISION);
  }
  $result = $query
    ->execute();
  $num_results = isset($result) ? count($result) : 0;
  if (!isset($result) || $num_results != 1) {
    return NULL;
  }
  foreach ($result as $parent_type => $parents) {
    foreach (array_keys($parents) as $parent_id) {
      return lingotek_entity_load_single($parent_type, $parent_id);
    }
  }
}