# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
use Modern::Perl;
+
+use File::Basename qw/basename/;
+
use C4::Context;
=head1 NAME
my $self = {};
$self->{configuration} = _load_configuration(
- C4::Context->config("interlibrary_loans"),
- C4::Context->preference("UnmediatedILL")
+ C4::Context->config("interlibrary_loans")
);
bless $self, $class;
return $self->{configuration}->{backend_directory};
}
+=head3 available_backends
+
+Return a list of available backends.
+
+=cut
+
+sub available_backends {
+ my ( $self ) = @_;
+ my $backend_dir = $self->backend_dir;
+ my @backends = ();
+ @backends = glob "$backend_dir/*" if ( $backend_dir );
+ @backends = map { basename($_) } @backends;
+ return \@backends;
+}
+
+=head3 has_branch
+
+Return whether a 'branch' block is defined
+
+=cut
+
+sub has_branch {
+ my ( $self ) = @_;
+ return $self->{configuration}->{raw_config}->{branch};
+}
+
=head3 partner_code
$partner_code = $config->partner_code($new_code);
=head3 getPrefixes
- my $prefixes = $config->getPrefixes('brw_cat' | 'branch');
+ my $prefixes = $config->getPrefixes();
-Return the prefix for ILLs defined by our config.
+Return the branch prefix for ILLs defined by our config.
=cut
sub getPrefixes {
- my ( $self, $type ) = @_;
- die "Unexpected type." unless ( $type eq 'brw_cat' || $type eq 'branch' );
- my $values = $self->{configuration}->{prefixes}->{$type};
- $values->{default} = $self->{configuration}->{prefixes}->{default};
- return $values;
+ my ( $self ) = @_;
+ return $self->{configuration}->{prefixes}->{branch};
}
=head3 getLimitRules
=cut
sub _load_configuration {
- my ( $xml_config, $unmediated ) = @_;
+ my ( $xml_config ) = @_;
my $xml_backend_dir = $xml_config->{backend_directory};
# Default data structure to be returned
# ILL Partners
$configuration->{partner_code} = $xml_config->{partner_code} || 'ILLLIBS';
- die "No DEFAULT_FORMATS has been defined in koha-conf.xml, but UNMEDIATEDILL is active."
- if ( $unmediated && !$configuration->{default_formats}->{default} );
-
return $configuration;
}