function content_moderation_post_update_set_default_moderation_state in Drupal 8
Set the default moderation state for new content to 'draft'.
File
- core/
modules/ content_moderation/ content_moderation.post_update.php, line 104 - Post update functions for the Content Moderation module.
Code
function content_moderation_post_update_set_default_moderation_state(&$sandbox) {
\Drupal::classResolver(ConfigEntityUpdater::class)
->update($sandbox, 'workflow', function (Workflow $workflow) {
if ($workflow
->get('type') === 'content_moderation') {
$configuration = $workflow
->getTypePlugin()
->getConfiguration();
$configuration['default_moderation_state'] = 'draft';
$workflow
->getTypePlugin()
->setConfiguration($configuration);
return TRUE;
}
return FALSE;
});
}