Lines 42-47
sub _type {
Link Here
|
42 |
return 'SftpServer'; |
42 |
return 'SftpServer'; |
43 |
} |
43 |
} |
44 |
|
44 |
|
|
|
45 |
=head3 _polymorphic_field |
46 |
|
47 |
Return the field in the table that defines the polymorphic class to be built |
48 |
|
49 |
=cut |
50 |
|
51 |
sub _polymorphic_field { |
52 |
return 'transport'; # This field defines which subclass to use |
53 |
} |
54 |
|
55 |
=head3 _polymorphic_map |
56 |
|
57 |
Return the mapping for field value to class name for the polymorphic class |
58 |
|
59 |
=cut |
60 |
|
61 |
sub _polymorphic_map { |
62 |
return { |
63 |
sftp => 'Koha::File::Transport::SFTP', |
64 |
ftp => 'Koha::File::Transport::FTP', |
65 |
}; |
66 |
} |
67 |
|
45 |
=head3 object_class |
68 |
=head3 object_class |
46 |
|
69 |
|
47 |
Return object class |
70 |
Return object class |
Lines 49-55
Return object class
Link Here
|
49 |
=cut |
72 |
=cut |
50 |
|
73 |
|
51 |
sub object_class { |
74 |
sub object_class { |
52 |
return 'Koha::SFTP::Server'; |
75 |
my ( $self, $object ) = @_; |
|
|
76 |
|
77 |
return 'Koha::File::Transport' unless $object; |
78 |
|
79 |
my $field = $self->_polymorphic_field; |
80 |
my $map = $self->_polymorphic_map; |
81 |
|
82 |
return $map->{ lc( $object->$field ) } || 'Koha::File::Transport'; |
53 |
} |
83 |
} |
54 |
|
84 |
|
55 |
1; |
85 |
1; |
56 |
- |
|
|