You are here

function content_translation_translate_access in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/content_translation/content_translation.module \content_translation_translate_access()

Access callback for the translation overview page.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity whose translation overview should be displayed.

Return value

\Drupal\Core\Access\AccessResultInterface The access result.

1 call to content_translation_translate_access()
CommentLazyBuilders::access in core/modules/comment/src/CommentLazyBuilders.php
Wraps content_translation_translate_access.
1 string reference to 'content_translation_translate_access'
content_translation_entity_type_alter in core/modules/content_translation/content_translation.module
Implements hook_entity_type_alter().

File

core/modules/content_translation/content_translation.module, line 374
Allows entities to be translated into different languages.

Code

function content_translation_translate_access(EntityInterface $entity) {
  $account = \Drupal::currentUser();
  $condition = $entity instanceof ContentEntityInterface && $entity
    ->access('view') && !$entity
    ->getUntranslated()
    ->language()
    ->isLocked() && \Drupal::languageManager()
    ->isMultilingual() && $entity
    ->isTranslatable() && ($account
    ->hasPermission('create content translations') || $account
    ->hasPermission('update content translations') || $account
    ->hasPermission('delete content translations') || $account
    ->hasPermission('translate editable entities') && $entity
    ->access('update'));
  return AccessResult::allowedIf($condition)
    ->cachePerPermissions()
    ->addCacheableDependency($entity);
}