Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ContentTranslationPermissions.php

function ContentTranslationPermissions::buildBundlePermission

Builds a content translation permission array for a bundle.

Parameters

\Drupal\Core\Entity\EntityTypeInterface $entity_type: The entity type.

string $bundle: The bundle to build the translation permission for.

array $bundle_info: The bundle info.

Return value

array The permission details, keyed by 'title' and 'dependencies'.

1 call to ContentTranslationPermissions::buildBundlePermission()
ContentTranslationPermissions::contentPermissions in core/modules/content_translation/src/ContentTranslationPermissions.php
Returns an array of content translation permissions.

File

core/modules/content_translation/src/ContentTranslationPermissions.php, line 115

Class

ContentTranslationPermissions
Provides dynamic permissions for the content_translation module.

Namespace

Drupal\content_translation

Code

private function buildBundlePermission(EntityTypeInterface $entity_type, string $bundle, array $bundle_info) {
    $permission = [
        'title' => $this->t('Translate %bundle_label @entity_label', [
            '@entity_label' => $entity_type->getSingularLabel(),
            '%bundle_label' => $bundle_info['label'] ?? $bundle,
        ]),
    ];
    // If the entity type uses bundle entities, add a dependency on the bundle.
    $bundle_entity_type = $entity_type->getBundleEntityType();
    if ($bundle_entity_type && ($bundle_entity = $this->entityTypeManager
        ->getStorage($bundle_entity_type)
        ->load($bundle))) {
        $permission['dependencies'][$bundle_entity->getConfigDependencyKey()][] = $bundle_entity->getConfigDependencyName();
    }
    else {
        $permission['dependencies']['module'][] = $entity_type->getProvider();
    }
    return $permission;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal