public function ContentTranslationPermissions::contentPermissions in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/content_translation/src/ContentTranslationPermissions.php \Drupal\content_translation\ContentTranslationPermissions::contentPermissions()
Returns an array of content translation permissions.
Return value
array
1 string reference to 'ContentTranslationPermissions::contentPermissions'
- content_translation.permissions.yml in core/
modules/ content_translation/ content_translation.permissions.yml - core/modules/content_translation/content_translation.permissions.yml
File
- core/
modules/ content_translation/ src/ ContentTranslationPermissions.php, line 64 - Contains \Drupal\content_translation\ContentTranslationPermissions.
Class
- ContentTranslationPermissions
- Provides dynamic permissions for the content_translation module.
Namespace
Drupal\content_translationCode
public function contentPermissions() {
$permission = [];
// Create a translate permission for each enabled entity type and (optionally)
// bundle.
foreach ($this->entityManager
->getDefinitions() as $entity_type_id => $entity_type) {
if ($permission_granularity = $entity_type
->getPermissionGranularity()) {
$t_args = [
'@entity_label' => $entity_type
->getLowercaseLabel(),
];
switch ($permission_granularity) {
case 'bundle':
foreach ($this->entityManager
->getBundleInfo($entity_type_id) as $bundle => $bundle_info) {
if ($this->contentTranslationManager
->isEnabled($entity_type_id, $bundle)) {
$t_args['%bundle_label'] = isset($bundle_info['label']) ? $bundle_info['label'] : $bundle;
$permission["translate {$bundle} {$entity_type_id}"] = [
'title' => $this
->t('Translate %bundle_label @entity_label', $t_args),
];
}
}
break;
case 'entity_type':
if ($this->contentTranslationManager
->isEnabled($entity_type_id)) {
$permission["translate {$entity_type_id}"] = [
'title' => $this
->t('Translate @entity_label', $t_args),
];
}
break;
}
}
}
return $permission;
}