class JsonApiFacetsDeriver in JSON:API Search API 8
Derives a facet source plugin definition for every index.
Hierarchy
- class \Drupal\facets\FacetSource\FacetSourceDeriverBase implements ContainerDeriverInterface uses StringTranslationTrait
- class \Drupal\jsonapi_search_api_facets\Plugin\facets\facet_source\JsonApiFacetsDeriver
Expanded class hierarchy of JsonApiFacetsDeriver
File
- modules/
jsonapi_search_api_facets/ src/ Plugin/ facets/ facet_source/ JsonApiFacetsDeriver.php, line 11
Namespace
Drupal\jsonapi_search_api_facets\Plugin\facets\facet_sourceView source
class JsonApiFacetsDeriver extends FacetSourceDeriverBase {
/**
* {@inheritdoc}
*/
public function getDerivativeDefinitions($base_plugin_definition) {
$derivatives = [];
foreach ($this->entityTypeManager
->getStorage('search_api_index')
->getQuery()
->execute() as $index) {
// Only derive for an index that supports facets.
if ($this->entityTypeManager
->getStorage('search_api_index')
->load($index)
->getServerInstance()
->supportsFeature('search_api_facets')) {
$derivatives[$index] = [
'id' => $base_plugin_definition['id'] . PluginBase::DERIVATIVE_SEPARATOR . $index,
'display_id' => strtr('jsonapi_search_api_facets_!index', [
'!index' => $index,
]),
'label' => $this
->t('JSON:API Search API Facets: @index', [
'@index' => $index,
]),
'index' => $index,
] + $base_plugin_definition;
}
}
return $derivatives;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FacetSourceDeriverBase:: |
protected | property | List of derivative definitions. | |
FacetSourceDeriverBase:: |
protected | property | The entity manager. | |
FacetSourceDeriverBase:: |
protected | property | The search api display plugin manager. | |
FacetSourceDeriverBase:: |
public | function | Compares two plugin definitions according to their labels. | |
FacetSourceDeriverBase:: |
public static | function |
Creates a new class instance. Overrides ContainerDeriverInterface:: |
|
FacetSourceDeriverBase:: |
public | function |
Gets the definition of a derivative plugin. Overrides DeriverInterface:: |
|
FacetSourceDeriverBase:: |
public | function | Retrieves the entity manager. | |
FacetSourceDeriverBase:: |
public | function | Returns the display plugin manager. | |
FacetSourceDeriverBase:: |
public | function | Sets the entity manager. | |
FacetSourceDeriverBase:: |
public | function | Sets search api's display plugin manager. | |
JsonApiFacetsDeriver:: |
public | function |
Gets the definition of all derivatives of a base plugin. Overrides DeriverInterface:: |
|
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. |