Sha256: 61c76f05764714051d7c150180d356ba1f1db46ecb57cc3d803317fdb070b5a3

Contents?: true

Size: 1.11 KB

Versions: 9

Compression:

Stored size: 1.11 KB

Contents

# frozen_string_literal: true
module Hyrax
  ##
  # Searches for all collections that are parents of a given collection.
  class NestedCollectionsParentSearchBuilder < ::Hyrax::CollectionSearchBuilder
    include Hyrax::FilterByType
    attr_reader :child, :page, :limit

    # @param [Object] scope Typically the controller object
    # @param [ActiveFedora::Base] child The child collection
    def initialize(scope:, child:, page:)
      @child = child
      @page = page
      super(scope)
    end

    ##
    # Filters the query to only include the parent collections
    #
    # @param [Hash] solr_parameters
    #
    # @return [void]
    def parent_collections_only(solr_parameters)
      solr_parameters[:fq] ||= []
      solr_parameters[:fq] += [Hyrax::SolrQueryBuilderService.construct_query_for_ids(child.member_of_collection_ids)]
    end
    self.default_processor_chain += [:parent_collections_only]

    ##
    # @param [Hash] solr_parameters
    #
    # @return [void]
    def with_pagination(solr_parameters)
      solr_parameters[:page] = page
    end
    self.default_processor_chain += [:with_pagination]
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
hyrax-3.6.0 app/search_builders/hyrax/nested_collections_parent_search_builder.rb
hyrax-3.5.0 app/search_builders/hyrax/nested_collections_parent_search_builder.rb
hyrax-3.4.2 app/search_builders/hyrax/nested_collections_parent_search_builder.rb
hyrax-3.4.1 app/search_builders/hyrax/nested_collections_parent_search_builder.rb
hyrax-3.4.0 app/search_builders/hyrax/nested_collections_parent_search_builder.rb
hyrax-3.3.0 app/search_builders/hyrax/nested_collections_parent_search_builder.rb
hyrax-3.2.0 app/search_builders/hyrax/nested_collections_parent_search_builder.rb
hyrax-3.1.0 app/search_builders/hyrax/nested_collections_parent_search_builder.rb
hyrax-3.0.2 app/search_builders/hyrax/nested_collections_parent_search_builder.rb