Module: Blacklight::Facet

Extended by:
Deprecation
Included in:
Catalog, FacetsHelperBehavior, JsonPresenter
Defined in:
app/controllers/concerns/blacklight/facet.rb

Overview

These are methods that are used at both the view helper and controller layers They are only dependent on ‘blacklight_config` and `@response`

Instance Method Summary collapse

Instance Method Details

#facet_by_field_name(field_or_field_name, response = nil) ⇒ Blacklight::Solr::Response::Facets::FacetField

Deprecated.

Get a FacetField object from the @response



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'app/controllers/concerns/blacklight/facet.rb', line 49

def facet_by_field_name(field_or_field_name, response = nil)
  unless response
    Deprecation.warn(self, 'Calling facet_by_field_name without passing the ' \
      'second argument (response) is deprecated and will be removed in Blacklight ' \
      '8.0.0')
    response = @response
  end
  case field_or_field_name
  when String, Symbol
    facet_field = facet_configuration_for_field(field_or_field_name)
    response.aggregations[facet_field.field]
  when Blacklight::Configuration::FacetField
    response.aggregations[field_or_field_name.field]
  else
    # is this really a useful case?
    field_or_field_name
  end
end

#facet_paginator(field_config, response_data) ⇒ Blacklight::FacetPaginator

Deprecated.

Parameters:

  • field_config (Blacklight::Configuration::Facet)
  • response_data (Object)

Returns:



14
15
16
17
18
19
20
21
22
# File 'app/controllers/concerns/blacklight/facet.rb', line 14

def facet_paginator(field_config, response_data)
  blacklight_config.facet_paginator_class.new(
    response_data.items,
    sort: response_data.sort,
    offset: response_data.offset,
    prefix: response_data.prefix,
    limit: Deprecation.silence(Blacklight::Catalog) { facet_limit_for(field_config.key) }
  )
end

#facets_from_request(fields = facet_field_names, response = nil) ⇒ Array<Solr::Response::Facets::FacetField>

Deprecated.

Parameters:

  • fields (Array<String>) (defaults to: facet_field_names)

    a list of facet field names

Returns:



28
29
30
31
32
33
34
35
36
37
38
39
# File 'app/controllers/concerns/blacklight/facet.rb', line 28

def facets_from_request(fields = facet_field_names, response = nil)
  unless response
    Deprecation.warn(self, 'Calling facets_from_request without passing the ' \
      'second argument (response) is deprecated and will be removed in Blacklight ' \
      '8.0.0')
    response = @response
  end

  Deprecation.silence(Blacklight::Facet) do
    fields.map { |field| facet_by_field_name(field, response) }.compact
  end
end