You are here

public function SearchExcludeNodeSearch::indexStatus in Search Exclude (Node) 8

Same name and namespace in other branches
  1. 2.x src/Plugin/Search/SearchExcludeNodeSearch.php \Drupal\search_exclude\Plugin\Search\SearchExcludeNodeSearch::indexStatus()
  2. 2.0.x src/Plugin/Search/SearchExcludeNodeSearch.php \Drupal\search_exclude\Plugin\Search\SearchExcludeNodeSearch::indexStatus()

Reports the status of indexing.

The core search module only invokes this method on active module plugins. Implementing modules do not need to check whether they are active when calculating their return values.

Return value

array An associative array with the key-value pairs:

  • remaining: The number of items left to index.
  • total: The total number of items to index.

Overrides NodeSearch::indexStatus

File

src/Plugin/Search/SearchExcludeNodeSearch.php, line 70

Class

SearchExcludeNodeSearch
Search plugin to exclude node bundles from the Search module index.

Namespace

Drupal\search_exclude\Plugin\Search

Code

public function indexStatus() {
  if (!count($this->configuration['excluded_bundles'])) {
    return parent::indexStatus();
  }
  $total = $this->database
    ->query('SELECT COUNT(*) FROM {node} WHERE type NOT IN (:excluded_bundles[])', array(
    ':excluded_bundles[]' => $this->configuration['excluded_bundles'],
  ))
    ->fetchField();
  $remaining = $this->database
    ->query("SELECT COUNT(DISTINCT n.nid) FROM {node} n LEFT JOIN {search_dataset} sd ON sd.sid = n.nid AND sd.type = :type WHERE (sd.sid IS NULL OR sd.reindex <> 0) AND n.type NOT IN (:excluded_bundles[])", array(
    ':type' => $this
      ->getPluginId(),
    ':excluded_bundles[]' => $this->configuration['excluded_bundles'],
  ))
    ->fetchField();
  return array(
    'remaining' => $remaining,
    'total' => $total,
  );
}