function lightning_workflow_modules_installed in Lightning Workflow 8.2
Same name and namespace in other branches
- 8.3 lightning_workflow.module \lightning_workflow_modules_installed()
- 8 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 152 - 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('lightning_dev', $modules, TRUE)) {
/** @var \Drupal\Core\Extension\ModuleInstallerInterface $module_installer */
$module_installer = Drupal::service('module_installer');
// Install Lightning Page separately in order to ensure that the optional
// Pathauto config that it ships is installed too.
$module_installer
->install([
'lightning_page',
]);
// Lightning Workflow optionally integrates with Diff, and for testing
// purposes we'd like to enable that integration. In order to test with
// meaningful responsibility-based roles, we also enable Lightning Roles.
$module_installer
->install([
'diff',
'lightning_roles',
'moderation_sidebar',
'pathauto',
'quickedit',
'toolbar',
'views',
]);
// BigPipe breaks a couple of non-JS tests which expect to find local task
// links, but receive BigPipe placeholders instead. This is a bit of a
// sledgehammer approach, but until it's possible to disable a module during
// a single test, it's the best we can do.
$module_installer
->uninstall([
'big_pipe',
]);
// Add moderation to the page content type.
/** @var NodeTypeInterface $node_type */
$node_type = entity_load('node_type', 'page');
$node_type
->setThirdPartySetting('lightning_workflow', 'workflow', 'editorial');
lightning_workflow_node_type_insert($node_type);
// Allow the content view to filter by moderation state.
$view = entity_load('view', 'content')
->enforceIsNew();
lightning_workflow_view_presave($view);
$view
->enforceIsNew(FALSE)
->save();
}
}