+ /**
+ * Checks if an entity type uses Entity Translation.
+ *
+ * @param string $entity_type
+ * The entity type.
+ *
+ * @return bool
+ * Whether the entity type uses entity translation.
+ */
+ protected function isEntityTranslatable($entity_type) {
+ return in_array($entity_type, $this->variableGet('entity_translation_entity_types', []), TRUE);
+ }
+
+ /**
+ * Gets an entity source language from the 'entity_translation' table.
+ *
+ * @param string $entity_type
+ * The entity type.
+ * @param int $entity_id
+ * The entity ID.
+ *
+ * @return string|bool
+ * The entity source language or FALSE if no source language was found.
+ */
+ protected function getEntityTranslationSourceLanguage($entity_type, $entity_id) {
+ try {
+ return $this->select('entity_translation', 'et')
+ ->fields('et', ['language'])
+ ->condition('entity_type', $entity_type)
+ ->condition('entity_id', $entity_id)
+ ->condition('source', '')
+ ->execute()
+ ->fetchField();
+ }
+ // The table might not exist.
+ catch (\Exception $e) {
+ return FALSE;
+ }
+ }
+