diff --git a/core/modules/translation_entity/translation_entity.module b/core/modules/translation_entity/translation_entity.module index 91ee94c..e1d2669 100644 --- a/core/modules/translation_entity/translation_entity.module +++ b/core/modules/translation_entity/translation_entity.module @@ -9,6 +9,7 @@ use Drupal\Core\Entity\EntityFormControllerInterface; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityNG; +use Drupal\node\Plugin\Core\Entity\Node; /** * Implements hook_help(). @@ -343,6 +344,26 @@ function translation_entity_enabled($entity_type, $bundle = NULL, $skip_handler } /** + * Implements hook_node_access_records_alter(). + */ +function translation_entity_node_access_records_alter(&$grants, Node $node) { + $grants_per_language = array(); + if (translation_entity_enabled('node', $node->type)) { + $grant_languages = $node->getTranslationLanguages(FALSE); + foreach ($grants as $grant) { + if (!isset($grant['langcode'])) { + foreach ($grant_languages as $language) { + $new_grant = clone $grant; + $new_grant['langcode'] = $language->langcode; + $grants_per_language[] = $new_grant; + } + } + } + } + array_merge($grants, $grants_per_language); +} + +/** * Entity translation controller factory. * * @param string $entity_type