function lightning_workflow_install in Lightning Workflow 8.2
Same name and namespace in other branches
- 8.3 lightning_workflow.install \lightning_workflow_install()
- 8 lightning_workflow.install \lightning_workflow_install()
Implements hook_install().
File
- ./
lightning_workflow.install, line 15 - Contains installation and update routines for Lightning Workflow.
Code
function lightning_workflow_install() {
if (\Drupal::moduleHandler()
->moduleExists('lightning_roles')) {
lightning_workflow_modules_installed([
'lightning_roles',
]);
}
// Stop here during a config sync.
if (\Drupal::isConfigSyncing()) {
return;
}
$workflow = Workflow::load('editorial');
$configuration = $workflow
->get('type_settings');
$configuration['states']['review'] = [
'label' => 'In review',
'weight' => -1,
'published' => FALSE,
'default_revision' => FALSE,
];
// Anything in the review state can be sent back to draft, kept in review,
// or published.
$configuration['transitions']['review'] = [
'label' => 'Send to review',
'from' => [
'draft',
'review',
],
'to' => 'review',
'weight' => 0,
];
$configuration['transitions']['create_new_draft']['from'][] = 'review';
$configuration['transitions']['publish']['from'][] = 'review';
// Give the archived_published transition a clearer name.
$configuration['transitions']['archived_published']['label'] = 'Restore from archive';
// Allow transitioning from the archived to draft states, rendering the
// archived_draft transition redundant.
unset($configuration['transitions']['archived_draft']);
$configuration['transitions']['create_new_draft']['from'][] = 'archived';
$workflow
->set('type_settings', $configuration);
$workflow
->save();
foreach (NodeType::loadMultiple() as $node_type) {
lightning_workflow_node_type_insert($node_type);
}
}