You are here

function tmgmt_entity_get_translatable_bundles in Translation Management Tool 7

Helper function to get entity translatable bundles.

Note that for comment entity type it will return the same as for node as comment bundles have no use (i.e. in queries).

Parameters

string $entity_type: Drupal entity type.

Return value

array Array of key => values, where key is type and value its label.

5 calls to tmgmt_entity_get_translatable_bundles()
TMGMTEntityDefaultSourceUIController::getEntitiesTranslationData in sources/entity/tmgmt_entity.ui.inc
Gets entities data of provided type needed to build overview form list.
TMGMTEntityDefaultSourceUIController::overviewSearchFormPart in sources/entity/tmgmt_entity.ui.inc
Builds search form for entity sources overview.
TMGMTEntitySourcePluginController::getType in sources/entity/tmgmt_entity.plugin.inc
Returns the type of a job item.
TMGMTEntitySourceUIController::overviewFormHeader in sources/entity/ui/tmgmt_entity_ui.ui.inc
Gets overview form header.
tmgmt_entity_get_translatable_entities in sources/entity/tmgmt_entity.module
Gets translatable entities of a given type.

File

sources/entity/tmgmt_entity.module, line 63
Source plugin for the Translation Management system that handles entities.

Code

function tmgmt_entity_get_translatable_bundles($entity_type) {

  // If given entity type does not have entity translations enabled, no reason
  // to continue.
  if (!in_array($entity_type, variable_get('entity_translation_entity_types', array()))) {
    return array();
  }
  $entity_info = entity_get_info($entity_type);
  $translatable_bundle_types = array();
  foreach ($entity_info['bundles'] as $bundle_type => $bundle_definition) {
    if ($entity_type == 'comment') {
      $bundle_type = str_replace('comment_node_', '', $bundle_type);
      if (variable_get('language_content_type_' . $bundle_type) == ENTITY_TRANSLATION_ENABLED) {
        $translatable_bundle_types[$bundle_type] = $bundle_definition['label'];
      }
    }
    elseif ($entity_type == 'node') {
      if (variable_get('language_content_type_' . $bundle_type) == ENTITY_TRANSLATION_ENABLED) {
        $translatable_bundle_types[$bundle_type] = $bundle_definition['label'];
      }
    }
    else {
      $translatable_bundle_types[$bundle_type] = $bundle_definition['label'];
    }
  }
  return $translatable_bundle_types;
}