You are here

public function ViewsNaturalSortService::queueDataForRebuild in Views Natural Sort 8.2

File

src/ViewsNaturalSortService.php, line 225

Class

ViewsNaturalSortService
Service that manages Views Natural Sort records.

Namespace

Drupal\views_natural_sort

Code

public function queueDataForRebuild(array $entry_types = []) {
  if (empty($entry_types)) {
    $entry_types = $this->moduleHandler
      ->invokeAll('views_natural_sort_get_entry_types');
  }
  $queues = [];
  foreach ($entry_types as $entry_type) {
    $queues = array_unique(array_merge($queues, array_filter($this->moduleHandler
      ->invokeAll('views_natural_sort_queue_rebuild_data', $entry_type))));
  }
  $operations = [];
  foreach ($queues as $queue) {
    $operations[] = [
      [
        $this,
        'rebuildIndex',
      ],
      [
        $queue,
      ],
    ];
  }
  $batch = [
    'operations' => $operations,
    'title' => t('Rebuilding Views Natural Sort Indexing Entries'),
    'finished' => [
      $this,
      'finishRebuild',
    ],
  ];
  batch_set($batch);
}