From f0e3a3e5756a4a4247346eb7a02d8e7086bd5427 Mon Sep 17 00:00:00 2001 From: Jeremy Friesen Date: Mon, 19 Feb 2024 17:48:00 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Create=20admin=20set=20of=20conf?= =?UTF-8?q?igured=20type=20(#6701)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Prior to this commit, we were assuming that we'd create a `Hyrax::AdministrativeSet`; however given the configuration option this could mean we were creating an administrative set of a type that we weren't expecting. --- app/services/hyrax/admin_set_create_service.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/services/hyrax/admin_set_create_service.rb b/app/services/hyrax/admin_set_create_service.rb index 722bc6ea2b..5b2e80b15c 100644 --- a/app/services/hyrax/admin_set_create_service.rb +++ b/app/services/hyrax/admin_set_create_service.rb @@ -84,12 +84,16 @@ def save_default? # Create an instance of `Hyrax::AdministrativeSet` with the suggested_id if supported. # @return [Hyrax::AdministrativeSet] the new admin set def create_admin_set(suggested_id:, title:) + # Leverage the configured admin class, if it is a Valkyrie resource, otherwise fallback. + # Until we have fully moved to Valkyrie, we will need this logic. Once past, we can + # use `Hyrax.config.admin_set_class` + klass = Hyrax.config.admin_set_class < Valkyrie::Resource ? Hyrax.config.admin_set_class : Hyrax::AdministrativeSet if suggested_id.blank? || Hyrax.config.disable_wings # allow persister to assign id - Hyrax::AdministrativeSet.new(title: Array.wrap(title)) + klass.new(title: Array.wrap(title)) else # use suggested_id - Hyrax::AdministrativeSet.new(id: suggested_id, title: Array.wrap(title)) + klass.new(id: suggested_id, title: Array.wrap(title)) end end