public function SearchStorage::loadBySearchPlugin in Search API Autocomplete 8
Loads the search that uses the given search plugin, if one exists.
Parameters
string $plugin_id: The search plugin ID.
Return value
\Drupal\search_api_autocomplete\SearchInterface|null The autocomplete search entity with that plugin, or NULL if none exists.
File
- src/
Entity/ SearchStorage.php, line 21
Class
- SearchStorage
- Provides a storage handler for our search entity.
Namespace
Drupal\search_api_autocomplete\EntityCode
public function loadBySearchPlugin($plugin_id) {
// @todo Change to the following once #2899014 gets fixed.
// $matching_entities = $this->getQuery()
// ->exists("search_settings.$plugin_id")
// ->execute();
/** @var \Drupal\search_api_autocomplete\SearchInterface $search */
foreach ($this
->loadMultiple() as $search) {
if ($search
->getSearchPluginId() === $plugin_id) {
return $search;
}
}
return NULL;
}