You are here

function tmgmt_update_8009 in Translation Management Tool 8

Update the job item overview view to use the new state filter configuration.

File

./tmgmt.install, line 119
Update function for the tmgmt module.

Code

function tmgmt_update_8009() {
  \Drupal::service('plugin.manager.views.filter')
    ->clearCachedDefinitions();
  $config = \Drupal::configFactory()
    ->getEditable('views.view.tmgmt_translation_all_job_items');

  // Make sure that we only update it if the view exists and has a state filter.
  $prefix = 'display.default.display_options.filters.state';
  if (!$config
    ->isNew() && $config
    ->get($prefix)) {
    $config
      ->set($prefix . '.operator', 'job_item_state');
    $config
      ->set($prefix . '.value', [
      JobItemInterface::STATE_REVIEW => JobItemInterface::STATE_REVIEW,
    ]);
    $config
      ->set($prefix . '.is_grouped', FALSE);
    $config
      ->set($prefix . '.group_items', []);
    $config
      ->set($prefix . '.plugin_id', 'tmgmt_job_item_filter');
    $config
      ->save(TRUE);
  }
}