diff --git a/entity_translation.admin.inc b/entity_translation.admin.inc index c1457c9..e9a9f5e 100644 --- a/entity_translation.admin.inc +++ b/entity_translation.admin.inc @@ -204,6 +204,8 @@ function entity_translation_overview($entity_type, $entity, $callback = NULL) { } $handler = entity_translation_get_handler($entity_type, $entity); + // Ensure $entity holds an entity object and not an id. + $entity = $handler->getEntity(); $handler->initPathScheme(); // Initialize translations if they are empty. @@ -387,7 +389,8 @@ function entity_translation_delete_confirm($form, $form_state, $entity_type, $en $form = array( '#handler' => $handler, '#entity_type' => $entity_type, - '#entity' => $entity, + // Ensure $entity holds an entity object and not an id. + '#entity' => $handler->getEntity(), '#language' => $langcode, ); diff --git a/entity_translation.module b/entity_translation.module index cd9d234..f75a7ce 100644 --- a/entity_translation.module +++ b/entity_translation.module @@ -693,8 +693,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); + // Ensure $entity holds an entity object and not an id. + $entity = $handler->getEntity(); + $enabled = entity_translation_enabled($entity_type, $entity); - return $enabled && entity_translation_get_handler($entity_type, $entity)->getLanguage() != LANGUAGE_NONE; + return $enabled && $handler->getLanguage() != LANGUAGE_NONE; } return FALSE; } @@ -1761,6 +1765,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 ae7ede3..184626f 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 @@ -749,6 +757,13 @@ class EntityTranslationDefaultHandler implements EntityTranslationHandlerInterfa } /** + * @see EntityTranslationHandlerInterface::getEntity() + */ + public function getEntity() { + return $this->entity; + } + + /** * @see EntityTranslationHandlerInterface::isWrappedEntity() */ public function isWrappedEntity($entity_type, $entity) {