diff --git a/entity_translation.admin.inc b/entity_translation.admin.inc index 11da698..f3a3a04 100644 --- a/entity_translation.admin.inc +++ b/entity_translation.admin.inc @@ -204,6 +204,10 @@ function entity_translation_overview($entity_type, $entity, $callback = NULL) { } $handler = entity_translation_get_handler($entity_type, $entity); + // In some cases the entity passed as an argument is not an entity, however, + // the handler is smart enough to figure this out so let's just ask the handler + // for the usable entity. + $entity = $handler->getEntity(); $handler->initPathScheme(); // Initialize translations if they are empty. @@ -358,7 +362,7 @@ function entity_translation_delete_confirm($form, $form_state, $entity_type, $en $form = array( '#handler' => $handler, '#entity_type' => $entity_type, - '#entity' => $entity, + '#entity' => $handler->getEntity(), '#language' => $langcode, ); diff --git a/entity_translation.module b/entity_translation.module index 8081af2..0a21a57 100644 --- a/entity_translation.module +++ b/entity_translation.module @@ -698,9 +698,12 @@ function entity_translation_admin_paths() { */ function entity_translation_tab_access($entity_type, $entity) { if (drupal_multilingual() && (user_access('translate any entity') || user_access("translate $entity_type entities"))) { + $handler = entity_translation_get_handler($entity_type, $entity); + $entity = $handler->getEntity(); + list(, , $bundle) = entity_extract_ids($entity_type, $entity); $enabled = entity_translation_enabled_bundle($entity_type, $bundle); - return $enabled && entity_translation_get_handler($entity_type, $entity)->getLanguage() != LANGUAGE_NONE; + return $enabled && $handler->getLanguage() != LANGUAGE_NONE; } return FALSE; } @@ -1698,6 +1701,9 @@ function entity_translation_get_handler($entity_type = NULL, $entity = NULL, $up return NULL; } } + elseif (is_numeric($entity)) { + $entity = reset(entity_load($entity_type, array($entity))); + } elseif (is_string($entity)) { $entity = entity_create_stub_entity($entity_type, array(NULL, NULL, $entity)); } diff --git a/includes/translation.handler.inc b/includes/translation.handler.inc index d0558c4..228d135 100644 --- a/includes/translation.handler.inc +++ b/includes/translation.handler.inc @@ -123,6 +123,14 @@ interface EntityTranslationHandlerInterface { public function setEntity($entity); /** + * Retrieve the current entity. + * + * @param return + * The entity to be translated. + */ + public function getEntity(); + + /** * Checks that the wrapped entity matches the give entity * * @param $entity_type @@ -731,6 +739,13 @@ class EntityTranslationDefaultHandler implements EntityTranslationHandlerInterfa } /** + * @see EntityTranslationHandlerInterface::getEntity() + */ + public function getEntity() { + return $this->entity; + } + + /** * @see EntityTranslationHandlerInterface::isWrappedEntity() */ public function isWrappedEntity($entity_type, $entity) {