Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

localgov_workflows_modules_installed hook doesn't seem to have a matching update hook for existing installs #120

Open
bradley-baylis opened this issue Nov 6, 2024 · 0 comments

Comments

@bradley-baylis
Copy link

As the title says this hook doesn't have a corresponding update from what I can see for existing installs:

/**
 * Implements hook_modules_installed().
 */
function localgov_workflows_modules_installed($modules, $is_syncing) {

  // Fix the core moderated content view.
  if (in_array('localgov_workflows', $modules, TRUE) && !$is_syncing) {

    // Don't change things if the core editorial workflow is enabled.
    if (!is_null(\Drupal::entityTypeManager()->getStorage('workflow')->load('editorial'))) {
      return;
    }

    $moderated_content_view = \Drupal::entityTypeManager()
      ->getStorage('view')
      ->load('moderated_content');
    if ($moderated_content_view) {

      // Fix filters to match editorial workflow.
      $display = $moderated_content_view->get('display');
      $filters = $display['default']['display_options']['filters'];
      $filters['moderation_state']['value'] = [
        'localgov_editorial-draft' => 'localgov_editorial-draft',
        'localgov_editorial-review' => 'localgov_editorial-review',
        'localgov_editorial-archived' => 'localgov_editorial-archived',
      ];
      $filters['moderation_state_1']['value'] = [
        'localgov_editorial-published' => 'localgov_editorial-published',
      ];
      $display['default']['display_options']['filters'] = $filters;

      // Update no results text.
      $display['default']['display_options']['empty']['area_text_custom']['content'] = 'No unpublished content available. Pages in Draft, Review and Archived states appear here.';

      $moderated_content_view->set('display', $display);
      $moderated_content_view->save();
    }
  }
}

Noticed this when we had published content appearing in the 'Unpublished' report. We've already resolved this for ourselves by running the hook code and exporting the new view config, seems to have stopped the incorrect results coming through.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant