diff --git a/core/modules/content_moderation/src/EventSubscriber/ConfigImportSubscriber.php b/core/modules/content_moderation/src/EventSubscriber/ConfigImportSubscriber.php index a0598fa1d19af59f5948ca7a30f4e83649440282..930167f04f23383be87003fd965adca2630e8e9d 100644 --- a/core/modules/content_moderation/src/EventSubscriber/ConfigImportSubscriber.php +++ b/core/modules/content_moderation/src/EventSubscriber/ConfigImportSubscriber.php @@ -81,15 +81,18 @@ public function onConfigImporterValidate(ConfigImporterEvent $event) { * @param string $config_name * The configuration object name. * - * @return \Drupal\Core\Entity\EntityInterface|null - * An entity object. NULL if no matching entity is found. + * @return \Drupal\workflows\WorkflowInterface|null + * A workflow entity object. NULL if no matching entity is found. */ protected function getWorkflow($config_name) { $entity_type_id = $this->configManager->getEntityTypeIdByName($config_name); + if ($entity_type_id !== 'workflow') { + return; + } + /** @var \Drupal\Core\Config\Entity\ConfigEntityTypeInterface $entity_type */ $entity_type = $this->entityTypeManager->getDefinition($entity_type_id); $entity_id = ConfigEntityStorage::getIDFromConfigName($config_name, $entity_type->getConfigPrefix()); - /** @var \Drupal\workflows\WorkflowInterface $workflow */ return $this->entityTypeManager->getStorage($entity_type_id)->load($entity_id); } diff --git a/core/modules/content_moderation/tests/src/Kernel/ContentModerationWorkflowConfigTest.php b/core/modules/content_moderation/tests/src/Kernel/ContentModerationWorkflowConfigTest.php index 7e2d972a4dacda22f3e885420ee55f7347322b59..931056e3d67ca82ecb37d94e07de237dcd4a336d 100644 --- a/core/modules/content_moderation/tests/src/Kernel/ContentModerationWorkflowConfigTest.php +++ b/core/modules/content_moderation/tests/src/Kernel/ContentModerationWorkflowConfigTest.php @@ -79,9 +79,22 @@ protected function setUp() { * Test deleting a state via config import. */ public function testDeletingStateViaConfiguration() { + $config_sync = \Drupal::service('config.storage.sync'); + + // Alter the workflow data. $config_data = $this->config('workflows.workflow.editorial')->get(); unset($config_data['type_settings']['states']['test1']); - \Drupal::service('config.storage.sync')->write('workflows.workflow.editorial', $config_data); + $config_sync->write('workflows.workflow.editorial', $config_data); + + // Alter the data of another entity type. + $config_data = $this->config('node.type.example')->get(); + $config_data['description'] = 'A new description'; + $config_sync->write('node.type.example', $config_data); + + // Alter the values of simple config. + $config_data = $this->config('core.extension')->get(); + $config_data['module']['node'] = 1; + $config_sync->write('core.extension', $config_data); // There are no Nodes with the moderation state test1, so this should run // with no errors.