You are here

function entity_translation_enabled in Entity Translation 7

Determines whether the given entity type is translatable.

Parameters

$entity_type: The entity type enabled for translation.

$entity: (optional) The entity belonging to the bundle enabled for translation. A bundle name can alternatively be passed. If an empty value is passed the bundle-level check is skipped. Defaults to NULL.

$skip_handler: (optional) A boolean indicating whether skip checking if the entity type is registered as a field translation handler. Defaults to FALSE.

35 calls to entity_translation_enabled()
EntityTranslationDefaultHandler::entityFormLanguageWidget in includes/translation.handler.inc
EntityTranslationDefaultHandler::entityFormLanguageWidgetSubmit in includes/translation.handler.inc
EntityTranslationDefaultHandler::__construct in includes/translation.handler.inc
Initializes an instance of the translation handler.
entity_translation_admin_paths in ./entity_translation.module
Implements hook_admin_paths().
entity_translation_entity_info_alter in ./entity_translation.module
Implements hook_entity_info_alter().

... See full list

File

./entity_translation.module, line 1784

Code

function entity_translation_enabled($entity_type, $entity = NULL, $skip_handler = FALSE) {
  $enabled_types = variable_get('entity_translation_entity_types', array());
  $enabled = !empty($enabled_types[$entity_type]) && ($skip_handler || field_has_translation_handler($entity_type, 'entity_translation'));

  // If the entity type is not enabled or we are not checking bundle status, we
  // have a result.
  if (!$enabled || !isset($entity)) {
    return $enabled;
  }

  // Determine the bundle to check for translatability.
  $bundle = FALSE;
  if (is_object($entity)) {
    list(, , $bundle) = entity_extract_ids($entity_type, $entity);
  }
  elseif (is_string($entity)) {
    $bundle = $entity;
  }
  return $bundle && entity_translation_enabled_bundle($entity_type, $bundle);
}