You are here

function lightning_workflow_install in Lightning Workflow 8

Same name and namespace in other branches
  1. 8.3 lightning_workflow.install \lightning_workflow_install()
  2. 8.2 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' => 'Review',
    'from' => [
      'draft',
      'review',
    ],
    'to' => 'review',
    'weight' => 0,
  ];
  $configuration['transitions']['create_new_draft']['from'][] = 'review';
  $configuration['transitions']['publish']['from'][] = 'review';
  $workflow
    ->set('type_settings', $configuration);
  $workflow
    ->save();
  foreach (NodeType::loadMultiple() as $node_type) {
    lightning_workflow_node_type_insert($node_type);
  }
}