public function PluginHelper::createSearchPluginsForIndex in Search API Autocomplete 8
Creates objects for all search plugins associated with the given index.
Search plugins are first filtered by their "index" definition key and then via their getIndexId() method.
Parameters
string $index_id: The ID of the search index for which to create search plugins.
Return value
\Drupal\search_api_autocomplete\Search\SearchPluginInterface[] The created search plugin objects.
Overrides PluginHelperInterface::createSearchPluginsForIndex
File
- src/
Utility/ PluginHelper.php, line 150
Class
- PluginHelper
- Provides methods for creating autocomplete search plugins.
Namespace
Drupal\search_api_autocomplete\UtilityCode
public function createSearchPluginsForIndex($index_id) {
$definitions = $this->searchPluginManager
->getDefinitions();
$searches = [];
foreach ($definitions as $search_id => $definition) {
if (!empty($definition['index']) && $definition['index'] !== $index_id) {
continue;
}
/** @var \Drupal\search_api_autocomplete\Search\SearchPluginInterface $search */
$search = $this->searchPluginManager
->createInstance($search_id);
if ($search
->getIndexId() === $index_id) {
$searches[$search_id] = $search;
}
}
return $searches;
}