diff --git a/core/modules/content_translation/src/ContentTranslationPermissions.php b/core/modules/content_translation/src/ContentTranslationPermissions.php index 07779334c1..1d2fbce2c1 100644 --- a/core/modules/content_translation/src/ContentTranslationPermissions.php +++ b/core/modules/content_translation/src/ContentTranslationPermissions.php @@ -72,7 +72,9 @@ public function contentPermissions() { $permission["translate $bundle $entity_type_id"] = [ 'title' => $this->t('Translate %bundle_label @entity_label', $t_args), ]; - // @todo add dependency if the bundle is configurable. + if (($bundle_entity_type = $entity_type->getBundleEntityType()) && $bundle_entity = $this->entityManager->getStorage($bundle_entity_type)->load($bundle)) { + $permission["translate $bundle $entity_type_id"]['dependencies'][$bundle_entity->getConfigDependencyKey()][] = $bundle_entity->getConfigDependencyName(); + } } } break; diff --git a/core/modules/node/src/NodePermissions.php b/core/modules/node/src/NodePermissions.php index 4657973f70..bf4a246b43 100644 --- a/core/modules/node/src/NodePermissions.php +++ b/core/modules/node/src/NodePermissions.php @@ -28,8 +28,8 @@ public function nodeTypePermissions() { foreach (NodeType::loadMultiple() as $type) { $perms_to_add = array_map( function ($perm) use ($type) { - // This permission is generated in behalf of a node type text format, - // therefore add the node type as a config dependency. + // This permission is generated in behalf of a node type, therefore + // add the node type as a config dependency. $perm['dependencies'] = [ $type->getConfigDependencyKey() => [$type->getConfigDependencyName()], ]; @@ -42,7 +42,6 @@ function ($perm) use ($type) { return $perms; } - /** * Returns a list of node permissions for a given node type. * diff --git a/core/modules/rest/src/Plugin/rest/resource/EntityResource.php b/core/modules/rest/src/Plugin/rest/resource/EntityResource.php index 5d9849ded4..94baa54fd1 100644 --- a/core/modules/rest/src/Plugin/rest/resource/EntityResource.php +++ b/core/modules/rest/src/Plugin/rest/resource/EntityResource.php @@ -365,7 +365,10 @@ public function permissions() { // @see https://www.drupal.org/node/2664780 if ($this->configFactory->get('rest.settings')->get('bc_entity_resource_permissions')) { // The default Drupal 8.0.x and 8.1.x behavior. - return parent::permissions(); + return array_map(function ($permission_info) { + $permission_info['dependencies']['config'][] = 'rest.settings'; + return $permission_info; + }, parent::permissions()); } else { // The default Drupal 8.2.x behavior. diff --git a/core/modules/rest/src/RestPermissions.php b/core/modules/rest/src/RestPermissions.php index fd03582aed..045e8c902f 100644 --- a/core/modules/rest/src/RestPermissions.php +++ b/core/modules/rest/src/RestPermissions.php @@ -58,7 +58,16 @@ public function permissions() { foreach ($resource_configs as $resource_config) { $plugin = $resource_config->getResourcePlugin(); // @todo work out what to do here for permission dependencies. - $permissions = array_merge($permissions, $plugin->permissions()); + $permissions_to_add = array_map(function ($permission_info) use ($resource_config) { + $permission_info += ['dependencies' => []]; + $permission_info['dependencies'] += [ + $resource_config->getConfigDependencyKey() => [ + $resource_config->getConfigDependencyName(), + ], + ]; + return $permission_info; + }, $plugin->permissions()); + $permissions = array_merge($permissions, $permissions_to_add); } return $permissions; }