Skip to content

Commit

Permalink
Issue #3295862: [Deprecate] Remove Lightning Workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
sylus committed Jul 21, 2022
1 parent 3408faa commit b3ca85c
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions modules/custom/wxt_ext/wxt_ext_page/wxt_ext_page.module
Expand Up @@ -4,3 +4,32 @@
* @file
* Contains wxt_ext_page.module.
*/

use Drupal\content_moderation\Plugin\WorkflowType\ContentModerationInterface;
use Drupal\Core\Plugin\ObjectWithPluginCollectionInterface;
use Drupal\workflows\WorkflowInterface;

/**
* Implements hook_ENTITY_TYPE_presave().
*/
function wxt_ext_page_workflow_presave(WorkflowInterface $workflow) {
if (Drupal::isConfigSyncing()) {
return;
}
elseif ($workflow->isNew() && $workflow->id() === 'editorial' && Drupal::moduleHandler()->moduleExists('wxt_ext_workflow')) {
$type_plugin = $workflow->getTypePlugin();

if ($type_plugin instanceof ContentModerationInterface) {
$type_plugin->addEntityTypeAndBundle('node', 'page');

// Since this hook is invoked _after_ Workflow::preSave(), we need to
// ensure that the stored settings for the type plugin will be up-to-date
// with the changes we've made here.
if ($workflow instanceof ObjectWithPluginCollectionInterface) {
foreach ($workflow->getPluginCollections() as $key => $plugin_collection) {
$workflow->set($key, $plugin_collection->getConfiguration());
}
}
}
}
}

0 comments on commit b3ca85c

Please sign in to comment.