Unverified Commit 2534957a authored by larowlan's avatar larowlan

Issue #2900019 by tim.plunkett, joelpittet:...

Issue #2900019 by tim.plunkett, joelpittet: \Drupal\content_moderation\EventSubscriber\ConfigImportSubscriber causes errors when importing any non-workflow config
parent 1da4fed2
...@@ -81,15 +81,18 @@ public function onConfigImporterValidate(ConfigImporterEvent $event) { ...@@ -81,15 +81,18 @@ public function onConfigImporterValidate(ConfigImporterEvent $event) {
* @param string $config_name * @param string $config_name
* The configuration object name. * The configuration object name.
* *
* @return \Drupal\Core\Entity\EntityInterface|null * @return \Drupal\workflows\WorkflowInterface|null
* An entity object. NULL if no matching entity is found. * A workflow entity object. NULL if no matching entity is found.
*/ */
protected function getWorkflow($config_name) { protected function getWorkflow($config_name) {
$entity_type_id = $this->configManager->getEntityTypeIdByName($config_name); $entity_type_id = $this->configManager->getEntityTypeIdByName($config_name);
if ($entity_type_id !== 'workflow') {
return;
}
/** @var \Drupal\Core\Config\Entity\ConfigEntityTypeInterface $entity_type */ /** @var \Drupal\Core\Config\Entity\ConfigEntityTypeInterface $entity_type */
$entity_type = $this->entityTypeManager->getDefinition($entity_type_id); $entity_type = $this->entityTypeManager->getDefinition($entity_type_id);
$entity_id = ConfigEntityStorage::getIDFromConfigName($config_name, $entity_type->getConfigPrefix()); $entity_id = ConfigEntityStorage::getIDFromConfigName($config_name, $entity_type->getConfigPrefix());
/** @var \Drupal\workflows\WorkflowInterface $workflow */
return $this->entityTypeManager->getStorage($entity_type_id)->load($entity_id); return $this->entityTypeManager->getStorage($entity_type_id)->load($entity_id);
} }
......
...@@ -79,9 +79,22 @@ protected function setUp() { ...@@ -79,9 +79,22 @@ protected function setUp() {
* Test deleting a state via config import. * Test deleting a state via config import.
*/ */
public function testDeletingStateViaConfiguration() { public function testDeletingStateViaConfiguration() {
$config_sync = \Drupal::service('config.storage.sync');
// Alter the workflow data.
$config_data = $this->config('workflows.workflow.editorial')->get(); $config_data = $this->config('workflows.workflow.editorial')->get();
unset($config_data['type_settings']['states']['test1']); 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 // There are no Nodes with the moderation state test1, so this should run
// with no errors. // with no errors.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment