From af14810bac938d81cddcddbfdef3e580514cb25d Mon Sep 17 00:00:00 2001 From: Joe Atzberger Date: Thu, 29 Nov 2007 17:43:04 -0600 Subject: [PATCH] Context.pm: obvious code consolidation, perldoc corrections. Signed-off-by: Chris Cormack Signed-off-by: Joshua Ferraro --- C4/Context.pm | 58 ++++++++++++++++++--------------------------------- 1 file changed, 20 insertions(+), 38 deletions(-) diff --git a/C4/Context.pm b/C4/Context.pm index 5ff2474a06..63ad238b12 100644 --- a/C4/Context.pm +++ b/C4/Context.pm @@ -141,6 +141,7 @@ $context = undef; # Initially, no context is set =item KOHAVERSION returns the kohaversion stored in kohaversion.pl file + =cut sub KOHAVERSION { @@ -358,50 +359,29 @@ Cnew> will not return it. =cut -#' -sub config -{ - my $self = shift; - my $var = shift; # The config variable to return - - return undef if !defined($context->{"config"}); - # Presumably $self->{config} might be - # undefined if the config file given to &new - # didn't exist, and the caller didn't bother - # to check the return value. +sub _common_config ($$) { + my $var = shift; + my $term = shift; + return undef if !defined($context->{$term}); + # Presumably $self->{$term} might be + # undefined if the config file given to &new + # didn't exist, and the caller didn't bother + # to check the return value. # Return the value of the requested config variable - return $context->{"config"}->{$var}; + return $context->{$term}->{$var}; } -sub zebraconfig -{ - my $self = shift; - my $var = shift; # The config variable to return - - return undef if !defined($context->{"server"}); - # Presumably $self->{config} might be - # undefined if the config file given to &new - # didn't exist, and the caller didn't bother - # to check the return value. - - # Return the value of the requested config variable - return $context->{"server"}->{$var}; +sub config { + return _common_config($_[1],'config'); } -sub ModZebrations -{ - my $self = shift; - my $var = shift; # The config variable to return - - return undef if !defined($context->{"serverinfo"}); - # Presumably $self->{config} might be - # undefined if the config file given to &new - # didn't exist, and the caller didn't bother - # to check the return value. - - # Return the value of the requested config variable - return $context->{"serverinfo"}->{$var}; +sub zebraconfig { + return _common_config($_[1],'server'); +} +sub ModZebrations { + return _common_config($_[1],'serverinfo'); } + =item preference $sys_preference = C4::Context->preference("some_variable"); @@ -943,6 +923,8 @@ Specifies the configuration file to read. =head1 SEE ALSO +XML::Simple + =head1 AUTHORS Andrew Arensburger -- 2.39.5