function ContentTranslationManageAccessCheck::checkAccess
Same name in other branches
- 9 core/modules/content_translation/src/Access/ContentTranslationManageAccessCheck.php \Drupal\content_translation\Access\ContentTranslationManageAccessCheck::checkAccess()
- 8.9.x core/modules/content_translation/src/Access/ContentTranslationManageAccessCheck.php \Drupal\content_translation\Access\ContentTranslationManageAccessCheck::checkAccess()
- 11.x core/modules/content_translation/src/Access/ContentTranslationManageAccessCheck.php \Drupal\content_translation\Access\ContentTranslationManageAccessCheck::checkAccess()
Performs access checks for the specified operation.
Parameters
\Drupal\Core\Entity\ContentEntityInterface $entity: The entity being checked.
\Drupal\Core\Language\LanguageInterface $language: For an update or delete operation, the language code of the translation being updated or deleted.
string $operation: The operation to be checked.
Return value
\Drupal\Core\Access\AccessResultInterface An access result object.
1 call to ContentTranslationManageAccessCheck::checkAccess()
- ContentTranslationManageAccessCheck::access in core/
modules/ content_translation/ src/ Access/ ContentTranslationManageAccessCheck.php - Checks translation access for the entity and operation on the given route.
File
-
core/
modules/ content_translation/ src/ Access/ ContentTranslationManageAccessCheck.php, line 139
Class
- ContentTranslationManageAccessCheck
- Access check for entity translation CRUD operation.
Namespace
Drupal\content_translation\AccessCode
protected function checkAccess(ContentEntityInterface $entity, LanguageInterface $language, $operation) {
/** @var \Drupal\content_translation\ContentTranslationHandlerInterface $handler */
$handler = $this->entityTypeManager
->getHandler($entity->getEntityTypeId(), 'translation');
$translations = $entity->getTranslationLanguages();
$languages = $this->languageManager
->getLanguages();
$has_translation = isset($languages[$language->getId()]) && $language->getId() != $entity->getUntranslated()
->language()
->getId() && isset($translations[$language->getId()]);
return AccessResult::allowedIf($has_translation)->cachePerPermissions()
->addCacheableDependency($entity)
->andIf($handler->getTranslationAccess($entity, $operation));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.