Get the bundle of an entity

Public

</> CopyGet raw version
php
  1. function _entity_get_bundle($entity, $entity_type) {
  2. $info = entity_get_info($entity_type);
  3. if (empty($info['entity keys']['bundle'])) {
  4. return $entity_type;
  5. } else {
  6. return $entity->{$info['entity keys']['bundle']};
  7. }
  8. }