From d94c5714a03c0de73bd96038197e6cb414fd8572 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 --- Koha/Objects.pm | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/Koha/Objects.pm b/Koha/Objects.pm index 21b16d020bf..2774ce711f2 100644 --- a/Koha/Objects.pm +++ b/Koha/Objects.pm @@ -598,6 +598,35 @@ 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.49.0