Sha256: db5de60c3b014c40b7ee1544ed2159f7f181a85237bc030e907204ca3cccabf4

Contents?: true

Size: 1.09 KB

Versions: 4

Compression:

Stored size: 1.09 KB

Contents

# frozen_string_literal: true
module Hyrax
  ##
  # Searches for all collections that are parents of a given collection.
  class NestedCollectionsParentSearchBuilder < ::SearchBuilder
    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

4 entries across 4 versions & 1 rubygems

Version Path
hyrax-3.0.1 app/search_builders/hyrax/nested_collections_parent_search_builder.rb
hyrax-3.0.0 app/search_builders/hyrax/nested_collections_parent_search_builder.rb
hyrax-3.0.0.pre.rc4 app/search_builders/hyrax/nested_collections_parent_search_builder.rb
hyrax-3.0.0.pre.rc3 app/search_builders/hyrax/nested_collections_parent_search_builder.rb