function content_translation_translate_access

content_translation_translate_access(EntityInterface $entity)

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.

File

core/modules/content_translation/content_translation.module, line 280
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'));
  return AccessResult::allowedIf($condition)->cachePerPermissions()->addCacheableDependency($entity);
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!modules!content_translation!content_translation.module/function/content_translation_translate_access/8.1.x