View | Details | Raw Unified | Return to bug 39190
Collapse All | Expand All

(-)a/Koha/File/Transports.pm (-6 / +26 lines)
Lines 43-48 sub _type { Link Here
43
    return 'SftpServer';
43
    return 'SftpServer';
44
}
44
}
45
45
46
=head3 _polymorphic_field
47
48
Return the field in the table that defines the polymorphic class to be built
49
50
=cut
51
52
sub _polymorphic_field {
53
    return 'transport';    # This field defines which subclass to use
54
}
55
56
=head3 _polymorphic_map
57
58
Return the mapping for field value to class name for the polymorphic class
59
60
=cut
61
62
sub _polymorphic_map {
63
    return {
64
        sftp => 'Koha::File::Transport::SFTP',
65
        ftp  => 'Koha::File::Transport::FTP',
66
    };
67
}
68
46
=head3 object_class
69
=head3 object_class
47
70
48
Return object class dynamically based on transport
71
Return object class dynamically based on transport
Lines 54-65 sub object_class { Link Here
54
77
55
    return 'Koha::File::Transport' unless $object;
78
    return 'Koha::File::Transport' unless $object;
56
79
57
    my %class_map = (
80
    my $field = $self->_polymorphic_field;
58
        sftp => 'Koha::File::Transport::SFTP',
81
    my $map   = $self->_polymorphic_map;
59
        ftp  => 'Koha::File::Transport::FTP',
60
    );
61
82
62
    return $class_map{ lc( $object->transport ) } || 'Koha::File::Transport';
83
    return $map->{ lc( $object->$field ) } || 'Koha::File::Transport';
63
}
84
}
64
85
65
1;
86
1;
66
- 

Return to bug 39190