function ContentTranslationHandler::getTranslationAccess
Same name in other branches
- 9 core/modules/content_translation/src/ContentTranslationHandler.php \Drupal\content_translation\ContentTranslationHandler::getTranslationAccess()
- 10 core/modules/content_translation/src/ContentTranslationHandler.php \Drupal\content_translation\ContentTranslationHandler::getTranslationAccess()
- 11.x core/modules/content_translation/src/ContentTranslationHandler.php \Drupal\content_translation\ContentTranslationHandler::getTranslationAccess()
Overrides ContentTranslationHandlerInterface::getTranslationAccess
File
-
core/
modules/ content_translation/ src/ ContentTranslationHandler.php, line 288
Class
- ContentTranslationHandler
- Base class for content translation handlers.
Namespace
Drupal\content_translationCode
public function getTranslationAccess(EntityInterface $entity, $op) {
// @todo Move this logic into a translation access control handler checking also
// the translation language and the given account.
$entity_type = $entity->getEntityType();
$translate_permission = TRUE;
// If no permission granularity is defined this entity type does not need an
// explicit translate permission.
if (!$this->currentUser
->hasPermission('translate any entity') && ($permission_granularity = $entity_type->getPermissionGranularity())) {
$translate_permission = $this->currentUser
->hasPermission($permission_granularity == 'bundle' ? "translate {$entity->bundle()} {$entity->getEntityTypeId()}" : "translate {$entity->getEntityTypeId()}");
}
return AccessResult::allowedIf($translate_permission && $this->currentUser
->hasPermission("{$op} content translations"))
->cachePerPermissions();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.