Bugzilla – Attachment 179606 Details for
Bug 39190
Rework new (S)FTP classes to be polymorphic classes
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 39190: Update polymorhpic base class to identify itself
Bug-39190-Update-polymorhpic-base-class-to-identif.patch (text/plain), 1.83 KB, created by
Kyle M Hall (khall)
on 2025-03-21 13:37:29 UTC
(
hide
)
Description:
Bug 39190: Update polymorhpic base class to identify itself
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2025-03-21 13:37:29 UTC
Size:
1.83 KB
patch
obsolete
>From 5a8e79c9819631e44ee49ff273abc977015e386e Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Mon, 17 Mar 2025 15:13:05 +0000 >Subject: [PATCH] Bug 39190: Update polymorhpic base class to identify itself > >This patch adds _polymorphic_field and _polymorphic_map private methods >to the Koha::File::Transports class to more clearly identify this as a >polymorphic class base for TestBuilder. > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > Koha/File/Transports.pm | 31 ++++++++++++++++++++++++++----- > 1 file changed, 26 insertions(+), 5 deletions(-) > >diff --git a/Koha/File/Transports.pm b/Koha/File/Transports.pm >index 1c37ea76c59..932a7248696 100644 >--- a/Koha/File/Transports.pm >+++ b/Koha/File/Transports.pm >@@ -43,6 +43,29 @@ sub _type { > return 'SftpServer'; > } > >+=head3 _polymorphic_field >+ >+Return the field in the table that defines the polymorphic class to be built >+ >+=cut >+ >+sub _polymorphic_field { >+ return 'transport'; # This field defines which subclass to use >+} >+ >+=head3 _polymorphic_map >+ >+Return the mapping for field value to class name for the polymorphic class >+ >+=cut >+ >+sub _polymorphic_map { >+ return { >+ sftp => 'Koha::File::Transport::SFTP', >+ ftp => 'Koha::File::Transport::FTP', >+ }; >+} >+ > =head3 object_class > > Return object class dynamically based on transport >@@ -54,12 +77,10 @@ sub object_class { > > return 'Koha::File::Transport' unless $object; > >- my %class_map = ( >- sftp => 'Koha::File::Transport::SFTP', >- ftp => 'Koha::File::Transport::FTP', >- ); >+ my $field = $self->_polymorphic_field; >+ my $map = $self->_polymorphic_map; > >- return $class_map{ lc( $object->transport ) } || 'Koha::File::Transport'; >+ return $map->{ lc( $object->$field ) } || 'Koha::File::Transport'; > } > > 1; >-- >2.39.5 (Apple Git-154)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 39190
:
178555
|
178556
|
178557
|
178558
|
178559
|
178560
|
178561
|
178562
|
178563
|
178564
|
178565
|
178566
|
178567
|
178568
|
178569
|
178570
|
178571
|
179252
|
179253
|
179254
|
179255
|
179256
|
179257
|
179258
|
179259
|
179260
|
179261
|
179262
|
179263
|
179264
|
179265
|
179266
|
179267
|
179268
|
179396
|
179397
|
179398
|
179399
|
179400
|
179401
|
179402
|
179403
|
179404
|
179405
|
179406
|
179407
|
179408
|
179409
|
179410
|
179411
|
179412
|
179413
|
179589
|
179590
|
179591
|
179592
|
179593
|
179594
|
179595
|
179596
|
179597
|
179598
|
179599
|
179600
|
179601
|
179602
|
179603
|
179604
|
179605
|
179606
|
179646
|
179647
|
179648
|
179649
|
179650
|
179651
|
179652
|
179653
|
179654
|
179655
|
179656
|
179657
|
179658
|
179659
|
179660
|
179661
|
179662
|
179663
|
179992
|
179993
|
179994
|
179995
|
179996
|
179997
|
179998
|
179999
|
180000
|
180001
|
180002
|
180003
|
180004
|
180005
|
180006
|
180010
|
180011
|
180012
|
180013
|
180014
|
180015
|
180016
|
180017
|
180018
|
180019
|
180020
|
180021
|
180022
|
180023
|
180024
|
180025