public function SolrDocumentDeriver::getDerivativeDefinitions in Search API Solr 8.3
Same name and namespace in other branches
- 4.x src/Plugin/DataType/Deriver/SolrDocumentDeriver.php \Drupal\search_api_solr\Plugin\DataType\Deriver\SolrDocumentDeriver::getDerivativeDefinitions()
Throws
\Drupal\Component\Plugin\Exception\PluginNotFoundException Thrown if the entity type doesn't exist.
\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException Thrown if the storage handler couldn't be loaded.
\Drupal\search_api\SearchApiException
Overrides DeriverBase::getDerivativeDefinitions
File
- src/
Plugin/ DataType/ Deriver/ SolrDocumentDeriver.php, line 70
Class
- SolrDocumentDeriver
- Provides data type plugins for each index.
Namespace
Drupal\search_api_solr\Plugin\DataType\DeriverCode
public function getDerivativeDefinitions($base_plugin_definition) {
// Also keep the 'solr_document' defined without any index.
$this->derivatives[''] = $base_plugin_definition;
// Load all indexes and filter out solr-based.
$indexes = $this->entityTypeManager
->getStorage('search_api_index')
->loadMultiple();
/* @var \Drupal\search_api\Entity\Index $entity */
foreach ($indexes as $index_id => $entity) {
$server = $entity
->getServerInstance();
if ($server && $server
->getBackend() instanceof SolrBackendInterface && Utility::hasIndexSolrDatasources($entity)) {
// @todo Does it make sense to get constraints from index entity?
$this->derivatives[$index_id] = [
'label' => $base_plugin_definition['label'] . ':' . $entity
->label(),
] + $base_plugin_definition;
}
}
return $this->derivatives;
}