Loading core/lib/Drupal/Core/Config/Action/ConfigActionManager.php +15 −2 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ namespace Drupal\Core\Config\Action; use Drupal\Component\Plugin\Exception\PluginNotFoundException; use Drupal\Component\Plugin\PluginBase; use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Config\Action\Attribute\ConfigAction; Loading Loading @@ -137,8 +138,20 @@ public function applyAction(string $action_id, string $configName, mixed $data): $action_id = $this->getShorthandActionIdsForEntityType($entity_type)[$action_id] ?? $action_id; } } try { /** @var \Drupal\Core\Config\Action\ConfigActionPluginInterface $action */ $action = $this->createInstance($action_id); } catch (PluginNotFoundException $e) { $entity_type = $this->configManager->getEntityTypeIdByName($configName); if ($entity_type) { $action_ids = $this->getShorthandActionIdsForEntityType($entity_type); $valid_ids = implode(', ', array_keys($action_ids)); throw new PluginNotFoundException($action_id, sprintf('The "%s" entity does not support the "%s" config action. Valid config actions for %s are: %s', $entity_type, $action_id, $entity_type, $valid_ids)); } throw $e; } foreach ($this->getConfigNamesMatchingExpression($configName) as $name) { $action->apply($name, $data); $typed_config = $this->typedConfig->createFromNameAndData($name, $this->configFactory->get($name)->getRawData()); Loading core/modules/content_moderation/tests/src/Kernel/ConfigAction/AddModerationConfigActionTest.php +1 −1 Original line number Diff line number Diff line Loading @@ -76,7 +76,7 @@ public function testWorkflowMustBeContentModeration(): void { public function testActionOnlyTargetsWorkflows(): void { $recipe = $this->createRecipe('user.role.anonymous'); $this->expectException(PluginNotFoundException::class); $this->expectExceptionMessage('The "addNodeTypes" plugin does not exist.'); $this->expectExceptionMessage('The "user_role" entity does not support the "addNodeTypes" config action.'); RecipeRunner::processRecipe($recipe); } Loading core/modules/field/tests/src/Kernel/AddToAllBundlesConfigActionTest.php +1 −1 Original line number Diff line number Diff line Loading @@ -74,7 +74,7 @@ public function testInstantiateNewFieldOnAllBundles(): void { // Expect an error when the 'addToAllBundles' action is invoked on anything // other than a field storage config entity. $this->expectException(PluginNotFoundException::class); $this->expectExceptionMessage('The "addToAllBundles" plugin does not exist.'); $this->expectExceptionMessage('The "user_role" entity does not support the "addToAllBundles" config action.'); $this->applyAction('user.role.anonymous'); } Loading core/tests/Drupal/KernelTests/Core/Recipe/PermissionsPerBundleTest.php +1 −1 Original line number Diff line number Diff line Loading @@ -124,7 +124,7 @@ public function testActionIsOnlyAvailableToUserRoles(): void { YAML; $this->expectException(PluginNotFoundException::class); $this->expectExceptionMessage('The "grantPermissionsForEachNodeType" plugin does not exist.'); $this->expectExceptionMessage('The "field_storage_config" entity does not support the "grantPermissionsForEachNodeType" config action.'); $this->applyRecipeFromString($recipe_data); } Loading core/tests/Drupal/KernelTests/Core/Recipe/RecipeRunnerTest.php +18 −1 Original line number Diff line number Diff line Loading @@ -203,6 +203,23 @@ public function testConfigActionsPreExistingConfig() :void { public function testInvalidConfigAction() :void { $recipe_data = <<<YAML name: Invalid config action install: - config_test config: actions: config_test.system: setFoo: 'Bar' YAML; $recipe = $this->createRecipe($recipe_data); $this->expectException(PluginNotFoundException::class); $this->expectExceptionMessage('The "setFoo" plugin does not exist.'); RecipeRunner::processRecipe($recipe); } public function testInvalidConfigActionAppliedOnConfigEntity() :void { $recipe_data = <<<YAML name: Invalid config action install: - config_test config: Loading @@ -215,7 +232,7 @@ public function testInvalidConfigAction() :void { $recipe = $this->createRecipe($recipe_data); $this->expectException(PluginNotFoundException::class); $this->expectExceptionMessage('The "setBody" plugin does not exist.'); $this->expectExceptionMessage('The "config_test" entity does not support the "setBody" config action.'); RecipeRunner::processRecipe($recipe); } Loading Loading
core/lib/Drupal/Core/Config/Action/ConfigActionManager.php +15 −2 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ namespace Drupal\Core\Config\Action; use Drupal\Component\Plugin\Exception\PluginNotFoundException; use Drupal\Component\Plugin\PluginBase; use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Config\Action\Attribute\ConfigAction; Loading Loading @@ -137,8 +138,20 @@ public function applyAction(string $action_id, string $configName, mixed $data): $action_id = $this->getShorthandActionIdsForEntityType($entity_type)[$action_id] ?? $action_id; } } try { /** @var \Drupal\Core\Config\Action\ConfigActionPluginInterface $action */ $action = $this->createInstance($action_id); } catch (PluginNotFoundException $e) { $entity_type = $this->configManager->getEntityTypeIdByName($configName); if ($entity_type) { $action_ids = $this->getShorthandActionIdsForEntityType($entity_type); $valid_ids = implode(', ', array_keys($action_ids)); throw new PluginNotFoundException($action_id, sprintf('The "%s" entity does not support the "%s" config action. Valid config actions for %s are: %s', $entity_type, $action_id, $entity_type, $valid_ids)); } throw $e; } foreach ($this->getConfigNamesMatchingExpression($configName) as $name) { $action->apply($name, $data); $typed_config = $this->typedConfig->createFromNameAndData($name, $this->configFactory->get($name)->getRawData()); Loading
core/modules/content_moderation/tests/src/Kernel/ConfigAction/AddModerationConfigActionTest.php +1 −1 Original line number Diff line number Diff line Loading @@ -76,7 +76,7 @@ public function testWorkflowMustBeContentModeration(): void { public function testActionOnlyTargetsWorkflows(): void { $recipe = $this->createRecipe('user.role.anonymous'); $this->expectException(PluginNotFoundException::class); $this->expectExceptionMessage('The "addNodeTypes" plugin does not exist.'); $this->expectExceptionMessage('The "user_role" entity does not support the "addNodeTypes" config action.'); RecipeRunner::processRecipe($recipe); } Loading
core/modules/field/tests/src/Kernel/AddToAllBundlesConfigActionTest.php +1 −1 Original line number Diff line number Diff line Loading @@ -74,7 +74,7 @@ public function testInstantiateNewFieldOnAllBundles(): void { // Expect an error when the 'addToAllBundles' action is invoked on anything // other than a field storage config entity. $this->expectException(PluginNotFoundException::class); $this->expectExceptionMessage('The "addToAllBundles" plugin does not exist.'); $this->expectExceptionMessage('The "user_role" entity does not support the "addToAllBundles" config action.'); $this->applyAction('user.role.anonymous'); } Loading
core/tests/Drupal/KernelTests/Core/Recipe/PermissionsPerBundleTest.php +1 −1 Original line number Diff line number Diff line Loading @@ -124,7 +124,7 @@ public function testActionIsOnlyAvailableToUserRoles(): void { YAML; $this->expectException(PluginNotFoundException::class); $this->expectExceptionMessage('The "grantPermissionsForEachNodeType" plugin does not exist.'); $this->expectExceptionMessage('The "field_storage_config" entity does not support the "grantPermissionsForEachNodeType" config action.'); $this->applyRecipeFromString($recipe_data); } Loading
core/tests/Drupal/KernelTests/Core/Recipe/RecipeRunnerTest.php +18 −1 Original line number Diff line number Diff line Loading @@ -203,6 +203,23 @@ public function testConfigActionsPreExistingConfig() :void { public function testInvalidConfigAction() :void { $recipe_data = <<<YAML name: Invalid config action install: - config_test config: actions: config_test.system: setFoo: 'Bar' YAML; $recipe = $this->createRecipe($recipe_data); $this->expectException(PluginNotFoundException::class); $this->expectExceptionMessage('The "setFoo" plugin does not exist.'); RecipeRunner::processRecipe($recipe); } public function testInvalidConfigActionAppliedOnConfigEntity() :void { $recipe_data = <<<YAML name: Invalid config action install: - config_test config: Loading @@ -215,7 +232,7 @@ public function testInvalidConfigAction() :void { $recipe = $this->createRecipe($recipe_data); $this->expectException(PluginNotFoundException::class); $this->expectExceptionMessage('The "setBody" plugin does not exist.'); $this->expectExceptionMessage('The "config_test" entity does not support the "setBody" config action.'); RecipeRunner::processRecipe($recipe); } Loading