public static function SuggestionHelper::index in Autocomplete Search Suggestions 8.2
Same name and namespace in other branches
- 8 src/SuggestionHelper.php \Drupal\suggestion\SuggestionHelper::index()
- 3.0.x src/SuggestionHelper.php \Drupal\suggestion\SuggestionHelper::index()
Create a suggestion index from content titles.
Parameters
int $last_nid: The last node ID processed.
int $limit: The query limit.
2 calls to SuggestionHelper::index()
- SuggestionIndexForm::submitForm in src/
Form/ SuggestionIndexForm.php - AJAX callback for the indexing form.
- suggestion_cron in ./
suggestion.module - Implements hook_cron().
File
- src/
SuggestionHelper.php, line 157
Class
- SuggestionHelper
- Provides helper methods for suggestions.
Namespace
Drupal\suggestionCode
public static function index($last_nid = 0, $limit = PHP_INT_MAX) {
$count =& drupal_static(__CLASS__ . '_' . __FUNCTION__ . '_count', 0);
$nid =& drupal_static(__CLASS__ . '_' . __FUNCTION__ . '_nid', 0);
self::setConfig('synced', TRUE);
if (!$last_nid) {
SuggestionStorage::deleteContentSuggestion();
SuggestionStorage::updateContentSrc();
}
$data = SuggestionStorage::getTitles($last_nid, $limit);
foreach ($data as $obj) {
$nid = $obj->nid;
$count += self::insert($obj->title, $obj->langcode, SuggestionStorage::CONTENT_BIT);
}
}