private function SearchApiExcludeEntityProcessor::getFieldOptions in Search API Exclude Entity 8
Find and return entity bundles enabled on the active index.
Parameters
string $entity_type: The entity type we are finding bundles for.
object $datasource: The data source from the active index.
Return value
array Options array with bundles.
1 call to SearchApiExcludeEntityProcessor::getFieldOptions()
- SearchApiExcludeEntityProcessor::buildConfigurationForm in src/
Plugin/ search_api/ processor/ SearchApiExcludeEntityProcessor.php - Form constructor.
File
- src/
Plugin/ search_api/ processor/ SearchApiExcludeEntityProcessor.php, line 128
Class
- SearchApiExcludeEntityProcessor
- Excludes entities marked as 'excluded' from being indexes.
Namespace
Drupal\search_api_exclude_entity\Plugin\search_api\processorCode
private function getFieldOptions($entity_type, $datasource) {
$field_map = $this
->getEntityFieldManager()
->getFieldMapByFieldType('search_api_exclude_entity');
$bundles = $datasource
->getBundles();
$options = [];
if (isset($field_map[$entity_type])) {
foreach ($field_map[$entity_type] as $field_id => $field) {
$bundles_filtered = [];
foreach ($field['bundles'] as $field_bundle) {
if (isset($bundles[$field_bundle])) {
$bundles_filtered[] = $field_bundle;
}
}
if (count($bundles_filtered) > 0) {
$options[$field_id] = $field_id . ' (' . implode(', ', $bundles_filtered) . ')';
}
}
}
return $options;
}