protected function IndexAddFieldsForm::getDatasourceListItem in Search API 8
Creates a list item for one datasource.
Parameters
\Drupal\search_api\Datasource\DatasourceInterface|null $datasource: The datasource, or NULL for general properties.
Return value
array A render array representing the given datasource and, possibly, its attached properties.
1 call to IndexAddFieldsForm::getDatasourceListItem()
- IndexAddFieldsForm::buildForm in src/
Form/ IndexAddFieldsForm.php - Form constructor.
File
- src/
Form/ IndexAddFieldsForm.php, line 229
Class
- IndexAddFieldsForm
- Provides a form for adding fields to a search index.
Namespace
Drupal\search_api\FormCode
protected function getDatasourceListItem(DatasourceInterface $datasource = NULL) {
$datasource_id = $datasource ? $datasource
->getPluginId() : NULL;
$datasource_id_param = $datasource_id ?: '';
$properties = $this->entity
->getPropertyDefinitions($datasource_id);
if ($properties) {
$active_property_path = '';
$active_datasource = $this
->getParameter('datasource');
if ($active_datasource !== NULL && $active_datasource == $datasource_id_param) {
$active_property_path = $this
->getParameter('property_path', '');
}
$base_url = $this->entity
->toUrl('add-fields');
$base_url
->setOption('query', [
'datasource' => $datasource_id_param,
]);
$item = $this
->getPropertiesList($properties, $active_property_path, $base_url, $datasource_id);
$item['#title'] = $datasource ? $datasource
->label() : $this
->t('General');
return $item;
}
return NULL;
}