class ViewsDeriver in Search API Autocomplete 8
Derives a search plugin definition for every view.
Hierarchy
- class \Drupal\Component\Plugin\Derivative\DeriverBase implements DeriverInterface
- class \Drupal\search_api_autocomplete\Search\SearchPluginDeriverBase implements ContainerDeriverInterface uses StringTranslationTrait
- class \Drupal\search_api_autocomplete\Plugin\search_api_autocomplete\search\ViewsDeriver
- class \Drupal\search_api_autocomplete\Search\SearchPluginDeriverBase implements ContainerDeriverInterface uses StringTranslationTrait
Expanded class hierarchy of ViewsDeriver
See also
\Drupal\search_api_autocomplete\Plugin\search_api_autocomplete\search\Views
File
- src/
Plugin/ search_api_autocomplete/ search/ ViewsDeriver.php, line 15
Namespace
Drupal\search_api_autocomplete\Plugin\search_api_autocomplete\searchView source
class ViewsDeriver extends SearchPluginDeriverBase {
/**
* {@inheritdoc}
*/
public function getDerivativeDefinitions($base_plugin_definition) {
if (!isset($this->derivatives)) {
$this->derivatives = [];
try {
/** @var \Drupal\Core\Entity\EntityStorageInterface $views_storage */
$views_storage = $this
->getEntityTypeManager()
->getStorage('view');
} catch (PluginException $e) {
return $this->derivatives;
}
/** @var \Drupal\views\ViewEntityInterface $view */
foreach ($views_storage
->loadMultiple() as $view) {
$index = SearchApiQuery::getIndexFromTable($view
->get('base_table'));
if (!$index instanceof IndexInterface) {
continue;
}
$this->derivatives[$view
->id()] = [
'label' => $view
->label(),
'index' => $index
->id(),
] + $base_plugin_definition;
}
}
return $this->derivatives;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DeriverBase:: |
public | function |
Gets the definition of a derivative plugin. Overrides DeriverInterface:: |
|
SearchPluginDeriverBase:: |
protected | property |
List of derivative definitions. Overrides DeriverBase:: |
|
SearchPluginDeriverBase:: |
protected | property | The entity manager. | |
SearchPluginDeriverBase:: |
protected static | property | Existing instances of this class. | |
SearchPluginDeriverBase:: |
public static | function |
Creates a new class instance. Overrides ContainerDeriverInterface:: |
|
SearchPluginDeriverBase:: |
public | function | Retrieves the entity manager. | |
SearchPluginDeriverBase:: |
public static | function | Resets the statically cached derivatives for all instances of this class. | |
SearchPluginDeriverBase:: |
public | function | Sets the entity manager. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. | |
ViewsDeriver:: |
public | function |
Gets the definition of all derivatives of a base plugin. Overrides DeriverBase:: |