function ContentTranslationManager::access

Same name and namespace in other branches
  1. main core/modules/content_translation/src/ContentTranslationManager.php \Drupal\content_translation\ContentTranslationManager::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.

Overrides ContentTranslationManagerInterface::access

File

core/modules/content_translation/src/ContentTranslationManager.php, line 121

Class

ContentTranslationManager
Provides common functionality for content translation.

Namespace

Drupal\content_translation

Code

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

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.