You are here

function lightning_workflow_update_8006 in Lightning Workflow 8.3

Removes deprecated relationship from moderation_history view.

File

./lightning_workflow.install, line 123
Contains installation and update routines for Lightning Workflow.

Code

function lightning_workflow_update_8006() {
  $config = Drupal::configFactory()
    ->getEditable('views.view.moderation_history');
  if ($config
    ->isNew()) {
    return;
  }
  $display_options = 'display.default.display_options';

  // Delete the deprecated relationship to the moderation state.
  $config
    ->clear("{$display_options}.relationships.moderation_state");

  // The moderation_state field should not use the deprecated moderation_state
  // relationship.
  $key = "{$display_options}.fields.moderation_state";
  $field = $config
    ->get($key);
  if ($field) {
    $field['table'] = Drupal::entityTypeManager()
      ->getDefinition('node')
      ->getRevisionDataTable();
    $field['relationship'] = 'none';
    $field['entity_type'] = 'node';
    unset($field['entity_field']);
    $config
      ->set($key, $field);
  }
  $config
    ->save();
}