You are here

public static function LingotekProfile::loadByEntity in Lingotek Translation 7.7

5 calls to LingotekProfile::loadByEntity()
LingotekProfile::getIdByEntity in lib/Drupal/lingotek/LingotekProfile.php
lingotek_entity_download_triggered in ./lingotek.module
lingotek_entity_load in ./lingotek.module
Implements hook_entity_load().
lingotek_grid_download_selected in ./lingotek.bulk_grid.inc
lingotek_managed_entity in ./lingotek.util.inc

File

lib/Drupal/lingotek/LingotekProfile.php, line 116
Defines LingotekProfile

Class

LingotekProfile
A class wrapper for Lingotek Profiles

Code

public static function loadByEntity($entity_type, $entity) {
  list($id, $vid, $bundle) = lingotek_entity_extract_ids($entity_type, $entity);
  $result = db_select('lingotek_entity_metadata', 'l')
    ->fields('l', array(
    'value',
  ))
    ->condition('l.entity_id', $id)
    ->condition('l.entity_type', $entity_type)
    ->condition('l.entity_key', 'profile')
    ->execute();
  if ($result) {
    $profile_id = $result
      ->fetchfield();
    if ($profile_id !== FALSE) {
      return self::loadById($profile_id);
    }
  }
  $source_locale = lingotek_entity_locale($entity_type, $entity);
  return self::loadByBundle($entity_type, $bundle, $source_locale);
}