From e1a014de2ae47877a7fdcc4fc844783a9b055c4e Mon Sep 17 00:00:00 2001 From: Benjamin Rokseth Date: Sun, 9 Sep 2018 23:15:24 +0200 Subject: [PATCH] Bug 21327: Add Core::Main Namespace - Core::Exceptions - Core::Prefs This is the main class of Core, along with siblings Prefs - to handle sysprefs and overrides, as well as Exceptions - Also included are the Makefile and koha-conf setup --- Core/Exceptions.pm | 21 +++++++++++++++++++++ Core/Main.pm | 12 ++++++++++++ Core/Prefs.pm | 30 ++++++++++++++++++++++++++++++ Makefile.PL | 1 + debian/templates/koha-conf-site.xml.in | 5 ++++- etc/koha-conf.xml | 5 ++++- 6 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 Core/Exceptions.pm create mode 100644 Core/Main.pm create mode 100644 Core/Prefs.pm diff --git a/Core/Exceptions.pm b/Core/Exceptions.pm new file mode 100644 index 0000000..a1a8b17 --- /dev/null +++ b/Core/Exceptions.pm @@ -0,0 +1,21 @@ +package Core::Exceptions; + +use Modern::Perl; + +use Exception::Class ( + "Core::Exception::Circulation", + "Core::Exception::Circulation::CheckinError" => { + description => "Error checking in", + isa => "Core::Exception::Circulation", + }, + "Core::Exception::Circulation::CheckoutError" => { + description => "Error checking out", + isa => "Core::Exception::Circulation", + }, + "Core::Exception::Circulation::RenewError" => { + description => "Error renewing item", + isa => "Core::Exception::Circulation", + } +); + +1; diff --git a/Core/Main.pm b/Core/Main.pm new file mode 100644 index 0000000..b5e1940 --- /dev/null +++ b/Core/Main.pm @@ -0,0 +1,12 @@ +package Core::Main; + +use strict; +use warnings; + +sub new { + + my $class = shift; + return bless {}, $class; +} + +1; diff --git a/Core/Prefs.pm b/Core/Prefs.pm new file mode 100644 index 0000000..9927656 --- /dev/null +++ b/Core/Prefs.pm @@ -0,0 +1,30 @@ +package Core::Prefs; + +use strict; +use warnings; + +use Carp; +use Koha::Config::SysPrefs; + +=head + args: systempreference overrides +=cut +sub new { + my ($class, $args) = @_; + + my $self = {}; + my $prefs; + my $tmp = Koha::Config::SysPrefs->search->unblessed; + foreach (@$tmp) { + $prefs->{$_->{variable}} = $_->{value}; + } + $args ||= {}; + $self->{prefs} = { + %$prefs, + %$args, + }; + + bless $self, $class; +} + +1; diff --git a/Makefile.PL b/Makefile.PL index ada08b9..ba90164 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -303,6 +303,7 @@ my $target_map = { './check_sysprefs.pl' => 'NONE', './circ' => 'INTRANET_CGI_DIR', './clubs' => 'INTRANET_CGI_DIR', + './Core' => 'PERL_MODULE_DIR', './course_reserves' => 'INTRANET_CGI_DIR', './docs/history.txt' => { target => 'DOC_DIR', trimdir => -1 }, './offline_circ' => 'INTRANET_CGI_DIR', diff --git a/debian/templates/koha-conf-site.xml.in b/debian/templates/koha-conf-site.xml.in index e6982bb..357cb8a 100644 --- a/debian/templates/koha-conf-site.xml.in +++ b/debian/templates/koha-conf-site.xml.in @@ -382,6 +382,9 @@ __END_SRU_PUBLICSERVER__ instance to be something other then the local timezone of the server. e.g. Antarctica/South_Pole --> __TIMEZONE__ - + + Core::Community::Circulation + Core::Community::Circulation::SIP + diff --git a/etc/koha-conf.xml b/etc/koha-conf.xml index 4af100e..0fae993 100644 --- a/etc/koha-conf.xml +++ b/etc/koha-conf.xml @@ -198,6 +198,9 @@ __PAZPAR2_TOGGLE_XML_POST__ instance to be something other then the local timezone of the server. e.g. Antarctica/South_Pole --> - + + Core::Community::Circulation + Core::Community::Circulation::SIP + -- 2.1.4