PageDeriver.php in Search API Autocomplete 8
File
src/Plugin/search_api_autocomplete/search/PageDeriver.php
View source
<?php
namespace Drupal\search_api_autocomplete\Plugin\search_api_autocomplete\search;
use Drupal\Component\Plugin\Exception\PluginException;
use Drupal\search_api_autocomplete\Search\SearchPluginDeriverBase;
class PageDeriver extends SearchPluginDeriverBase {
public function getDerivativeDefinitions($base_plugin_definition) {
if (!isset($this->derivatives)) {
$this->derivatives = [];
try {
$page_storage = $this
->getEntityTypeManager()
->getStorage('search_api_page');
$index_storage = $this
->getEntityTypeManager()
->getStorage('search_api_index');
} catch (PluginException $e) {
return $this->derivatives;
}
foreach ($page_storage
->loadMultiple() as $page) {
$index = $index_storage
->load($page
->getIndex());
$this->derivatives[$page
->id()] = [
'label' => $page
->label(),
'index' => $index
->id(),
] + $base_plugin_definition;
}
}
return $this->derivatives;
}
}
Classes
Name |
Description |
PageDeriver |
Derives a search plugin definition for every view. |