You are here

public function GranularItemProcessor::buildConfigurationForm in Facets 8

Adds a configuration form for this processor.

Parameters

array $form: The form.

\Drupal\Core\Form\FormStateInterface $form_state: The current form state.

\Drupal\facets\FacetInterface $facet: The facet this processor is being added to.

Overrides ProcessorPluginBase::buildConfigurationForm

File

src/Plugin/facets/processor/GranularItemProcessor.php, line 56

Class

GranularItemProcessor
Provides a processor for granularity.

Namespace

Drupal\facets\Plugin\facets\processor

Code

public function buildConfigurationForm(array $form, FormStateInterface $form_state, FacetInterface $facet) {
  $configuration = $this
    ->getConfiguration();
  $build['granularity'] = [
    '#type' => 'number',
    '#attributes' => [
      'min' => 1,
      'step' => 1,
    ],
    '#title' => $this
      ->t('Granularity'),
    '#default_value' => $configuration['granularity'],
    '#description' => $this
      ->t('The numeric size of the steps to group the result facets in.'),
  ];
  $build['min_value'] = [
    '#type' => 'number',
    '#title' => $this
      ->t('Minimum value'),
    '#default_value' => $configuration['min_value'],
    '#description' => $this
      ->t('If the minimum value is left empty it will be calculated by the search result'),
    '#size' => 10,
  ];
  $build['max_value'] = [
    '#type' => 'number',
    '#title' => $this
      ->t('Maximum value'),
    '#default_value' => $configuration['max_value'],
    '#description' => $this
      ->t('If the maximum value is left empty it will be calculated by the search result'),
    '#size' => 10,
  ];
  $build['include_lower'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Include lower bounds'),
    '#default_value' => $configuration['include_lower'],
  ];
  $build['include_upper'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Include upper bounds'),
    '#default_value' => $configuration['include_upper'],
  ];
  $build['include_edges'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Include first lower and last upper bound'),
    '#default_value' => $configuration['include_edges'],
  ];
  return $build;
}