You are here

public static function EntityHelper::getKey in Helper 7

1 call to EntityHelper::getKey()
FieldHelper::viewCustomField in lib/FieldHelper.php

File

lib/EntityHelper.php, line 404

Class

EntityHelper

Code

public static function getKey($entity_type, $entity, $key) {
  $info = entity_get_info($entity_type);
  if (isset($info['entity keys'][$key]) && isset($entity->{$info['entity keys'][$key]})) {
    return $entity->{$info['entity keys'][$key]};
  }
}