protected function BackendPluginBase::getSpecialFields in Search API 8
Creates dummy field objects for the "magic" fields present for every index.
Parameters
\Drupal\search_api\IndexInterface $index: The index for which to create the fields. (Needed since field objects always need an index set.)
\Drupal\search_api\Item\ItemInterface|null $item: (optional) If given, an item whose data should be used for the fields' values.
Return value
\Drupal\search_api\Item\FieldInterface[] An array of field objects for all "magic" fields, keyed by field IDs.
1 call to BackendPluginBase::getSpecialFields()
- Database::getSpecialFields in modules/
search_api_db/ src/ Plugin/ search_api/ backend/ Database.php - Creates dummy field objects for the "magic" fields present for every index.
1 method overrides BackendPluginBase::getSpecialFields()
- Database::getSpecialFields in modules/
search_api_db/ src/ Plugin/ search_api/ backend/ Database.php - Creates dummy field objects for the "magic" fields present for every index.
File
- src/
Backend/ BackendPluginBase.php, line 283
Class
- BackendPluginBase
- Defines a base class for backend plugins.
Namespace
Drupal\search_api\BackendCode
protected function getSpecialFields(IndexInterface $index, ItemInterface $item = NULL) {
$field_info = [
'type' => 'string',
'original type' => 'string',
];
$fields['search_api_id'] = $this
->getFieldsHelper()
->createField($index, 'search_api_id', $field_info);
$fields['search_api_datasource'] = $this
->getFieldsHelper()
->createField($index, 'search_api_datasource', $field_info);
$fields['search_api_language'] = $this
->getFieldsHelper()
->createField($index, 'search_api_language', $field_info);
if ($item) {
$fields['search_api_id']
->setValues([
$item
->getId(),
]);
$fields['search_api_datasource']
->setValues([
$item
->getDatasourceId(),
]);
$fields['search_api_language']
->setValues([
$item
->getLanguage(),
]);
}
return $fields;
}