diff --git a/src/Plugin/facets/processor/GranularItemProcessor.php b/src/Plugin/facets/processor/GranularItemProcessor.php index 05c590f..dd74f25 100644 --- a/src/Plugin/facets/processor/GranularItemProcessor.php +++ b/src/Plugin/facets/processor/GranularItemProcessor.php @@ -45,6 +45,7 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta $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.'), diff --git a/src/Plugin/facets/query_type/SearchApiGranular.php b/src/Plugin/facets/query_type/SearchApiGranular.php index 9eed200..34d7bf2 100644 --- a/src/Plugin/facets/query_type/SearchApiGranular.php +++ b/src/Plugin/facets/query_type/SearchApiGranular.php @@ -23,7 +23,7 @@ class SearchApiGranular extends QueryTypeRangeBase { public function calculateRange($value) { return [ 'start' => $value, - 'stop' => $value + $this->getGranularity(), + 'stop' => (int) $value + $this->getGranularity(), ]; } @@ -31,6 +31,7 @@ public function calculateRange($value) { * {@inheritdoc} */ public function calculateResultFilter($value) { + assert($this->getGranularity() > 0); return [ 'display' => $value - ($value % $this->getGranularity()), 'raw' => $value - ($value % $this->getGranularity()) ,