From 04358b7f170b289a93ad0520469f047cf586c681 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Mon, 31 Mar 2025 12:09:55 +0200 Subject: [PATCH] Bug 39488: Add template for required polymorphic class methods Signed-off-by: Tomas Cohen Arazi --- Koha/Objects.pm | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/Koha/Objects.pm b/Koha/Objects.pm index 21b16d020bf..472b3ee277d 100644 --- a/Koha/Objects.pm +++ b/Koha/Objects.pm @@ -598,6 +598,36 @@ For example, for holds, _type should return 'Reserve'. sub _type { } +=head3 _polymorphic_field + + sub _polymorphic_field { + return 'transport'; + } + +The _polymorphic_field method must be set for all child classes that implement +their own polymorphic children. + +It should return the field name that distinguishes the classes. + +=cut + +=head3 _polymorphic_map + + sub _polymorphic_map { + return { + sftp => 'Koha::File::Transport::SFTP', + ftp => 'Koha::File::Transport::FTP', + }; + } + +The _polymorphic_map method must be implemented by all child classes that implement +their own polymorphic children. + +It should return a simple hashmap mapping for field value to class name for the +polymorphic class using the value from the _polymorphic_field defined above. + +=cut + =head3 object_class This method must be set for all child classes. -- 2.51.0