function lightning_workflow_modules_installed in Lightning Workflow 8.3
Same name and namespace in other branches
- 8 lightning_workflow.module \lightning_workflow_modules_installed()
- 8.2 lightning_workflow.module \lightning_workflow_modules_installed()
Implements hook_modules_installed().
1 call to lightning_workflow_modules_installed()
- lightning_workflow_install in ./
lightning_workflow.install - Implements hook_install().
File
- ./
lightning_workflow.module, line 213 - Provides workflow enhancements for Drupal.
Code
function lightning_workflow_modules_installed(array $modules) {
// Don't do anything during config sync.
if (Drupal::isConfigSyncing()) {
return;
}
if (in_array('lightning_roles', $modules, TRUE)) {
Drupal::service('lightning.content_roles')
->grantPermissions('creator', [
'use editorial transition create_new_draft',
'use editorial transition review',
'view any unpublished content',
'view latest version',
'use moderation sidebar',
])
->grantPermissions('reviewer', [
'use editorial transition publish',
'use editorial transition review',
'use editorial transition archive',
'view any unpublished content',
'view latest version',
'access toolbar',
'use moderation sidebar',
]);
}
if (in_array('autosave_form', $modules, TRUE)) {
// Find all content types that would like to opt into autosave by default,
// either implicitly or explicitly. I'm not sure this can be done with a
// simple entity query, since it's not clear if one can specify a condition
// that a third-party setting is "not FALSE".
$node_types = array_filter(NodeType::loadMultiple(), function (NodeTypeInterface $node_type) {
return $node_type
->getThirdPartySetting('lightning_workflow', 'autosave', TRUE);
});
$node_types = array_keys($node_types);
Drupal::configFactory()
->getEditable('autosave_form.settings')
->set('interval', 20000)
->set('allowed_content_entity_types.node.bundles', array_combine($node_types, $node_types))
->save();
}
}