public function SiteNameProperty::buildConfigurationForm in Search API Field Map 8.2
Same name and namespace in other branches
- 8.3 src/Plugin/search_api/processor/Property/SiteNameProperty.php \Drupal\search_api_field_map\Plugin\search_api\processor\Property\SiteNameProperty::buildConfigurationForm()
- 8 src/Plugin/search_api/processor/Property/SiteNameProperty.php \Drupal\search_api_field_map\Plugin\search_api\processor\Property\SiteNameProperty::buildConfigurationForm()
- 4.x src/Plugin/search_api/processor/Property/SiteNameProperty.php \Drupal\search_api_field_map\Plugin\search_api\processor\Property\SiteNameProperty::buildConfigurationForm()
Constructs a configuration form for a field based on this property.
Parameters
\Drupal\search_api\Item\FieldInterface $field: The field for which the configuration form is constructed.
array $form: An associative array containing the initial structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the complete form.
Return value
array The form structure.
Overrides ConfigurablePropertyInterface::buildConfigurationForm
File
- src/
Plugin/ search_api/ processor/ Property/ SiteNameProperty.php, line 33
Class
- SiteNameProperty
- Defines a "site name" property.
Namespace
Drupal\search_api_field_map\Plugin\search_api\processor\PropertyCode
public function buildConfigurationForm(FieldInterface $field, array $form, FormStateInterface $form_state) {
$configuration = $field
->getConfiguration();
// Create a link to the Basic Site Settings Page from route.
$options = [
'attributes' => [
'target' => '_blank',
],
];
$basic_site_settings_page_url = Url::fromRoute('system.site_information_settings', [], $options);
$basic_site_settings_page_link = Link::fromTextAndUrl('Basic Site settings page', $basic_site_settings_page_url)
->toString();
$form['#attached']['library'][] = 'search_api/drupal.search_api.admin_css';
$form['#tree'] = TRUE;
$form['site_name_group'] = [
'#type' => 'fieldset',
'#title' => $this
->t('Site Name'),
'#description' => $this
->t('The name of the site from which this content originated. This can be useful if indexing multiple sites with a single search index.'),
];
$form['site_name_group']['use_system_site_name'] = [
'#type' => 'checkbox',
'#title' => '<b>' . $this
->t('Use the site name from ' . $basic_site_settings_page_link . ' > Site Details > Site Name') . '</b>',
'#default_value' => isset($configuration['use_system_site_name']) ? $configuration['use_system_site_name'] : 0,
'#description' => $this
->t('This option is recommended for multisite installations that share config across sites.'),
'#attributes' => [
'data-use-system-site-name' => TRUE,
],
];
$form['site_name_group']['site_name'] = [
'#type' => 'textfield',
'#title' => $this
->t('Site Name'),
'#description' => $this
->t('Create a Site Name.'),
'#default_value' => isset($configuration['site_name']) ? $configuration['site_name'] : '',
'#states' => [
'visible' => [
':input[data-use-system-site-name]' => [
'checked' => FALSE,
],
],
],
];
return $form;
}