public function FileSearch::indexStatus in Search File Attachments 8
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 SearchIndexingInterface::indexStatus
File
- src/
Plugin/ Search/ FileSearch.php, line 247
Class
- FileSearch
- Executes a keyword search for files against {file_managed} database table.
Namespace
Drupal\search_file_attachments\Plugin\SearchCode
public function indexStatus() {
$total = $this->database
->query('SELECT COUNT(*) FROM {file_managed} WHERE status = 1')
->fetchField();
$remaining = $this->database
->query("SELECT COUNT(*) FROM {file_managed} f LEFT JOIN {search_dataset} sd ON sd.sid = f.fid AND sd.type = :type WHERE f.status = 1 AND sd.sid IS NULL OR sd.reindex <> 0", array(
':type' => $this
->getPluginId(),
))
->fetchField();
return array(
'remaining' => $remaining,
'total' => $total,
);
}