public ContentTranslationHandler::getTranslationAccess(EntityInterface $entity, $op)
Checks if the user can perform the given operation on translations of the wrapped entity.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The entity whose translation has to be accessed.
$op: The operation to be performed on the translation. Possible values are:
- "create"
- "update"
- "delete"
Return value
\Drupal\Core\Access\AccessResultInterface The access result.
Overrides ContentTranslationHandlerInterface::getTranslationAccess
File
- core/modules/content_translation/src/ContentTranslationHandler.php, line 240
Class
- ContentTranslationHandler
- Base class for content translation handlers.
Namespace
Drupal\content_translation
Code
1 2 3 4 5 6 7 8 9 10 11 12 | 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(); } |
Please login to continue.