function translation_entity_add_access

Access callback for the translation addition page.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity being translated.

\Drupal\Core\Language\Language $source: The language of the values being translated.

\Drupal\Core\Language\Language $target: The language of the translated values.

1 string reference to 'translation_entity_add_access'
translation_entity_menu in drupal/core/modules/translation_entity/translation_entity.module
Implements hook_menu().

File

drupal/core/modules/translation_entity/translation_entity.module, line 247
Allows entities to be translated into different languages.

Code

function translation_entity_add_access(EntityInterface $entity, Language $source = NULL, Language $target = NULL) {
  $source = !empty($source) ? $source : $entity
    ->language();
  $target = !empty($target) ? $target : language(LANGUAGE_TYPE_CONTENT);
  $translations = $entity
    ->getTranslationLanguages();
  $languages = language_list();
  return $source->langcode != $target->langcode && isset($languages[$source->langcode]) && isset($languages[$target->langcode]) && !isset($translations[$target->langcode]) && translation_entity_access($entity, $target->langcode);
}