From c145457c7b43c16a97dbe608ab20f8670ac18f41 Mon Sep 17 00:00:00 2001
From: Andrew Isherwood <andrew.isherwood@ptfs-europe.com>
Date: Wed, 2 Oct 2019 16:39:47 +0100
Subject: [PATCH] Bug 23681: Add Koha::RestrictionType(s)

This patch adds the following objects:

Koha::RestrictionType
Koha::RestrictionTypes

Signed-off-by: Benjamin Veasey <B.T.Veasey@lboro.ac.uk>
Sponsored-by: Loughborough University
---
 Koha/RestrictionType.pm  | 42 ++++++++++++++++++++++
 Koha/RestrictionTypes.pm | 75 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 117 insertions(+)
 create mode 100644 Koha/RestrictionType.pm
 create mode 100644 Koha/RestrictionTypes.pm

diff --git a/Koha/RestrictionType.pm b/Koha/RestrictionType.pm
new file mode 100644
index 0000000000..1121c9ea83
--- /dev/null
+++ b/Koha/RestrictionType.pm
@@ -0,0 +1,42 @@
+package Koha::RestrictionType;
+
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 3 of the License, or (at your option) any later
+# version.
+#
+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with Koha; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+use Modern::Perl;
+
+use base qw(Koha::Object);
+
+=head1 NAME
+
+Koha::RestrictionType - Koha RestrictionType Object class
+
+=head1 API
+
+=head2 Class Methods
+
+=cut
+
+=head2 Internal methods
+
+=head3 type
+
+=cut
+
+sub _type {
+    return 'DebarmentType';
+}
+
+1;
diff --git a/Koha/RestrictionTypes.pm b/Koha/RestrictionTypes.pm
new file mode 100644
index 0000000000..560e5fdbba
--- /dev/null
+++ b/Koha/RestrictionTypes.pm
@@ -0,0 +1,75 @@
+package Koha::RestrictionTypes;
+
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 3 of the License, or (at your option) any later
+# version.
+#
+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with Koha; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+use Modern::Perl;
+
+use Carp;
+
+use C4::Context;
+
+use Koha::Database;
+use Koha::RestrictionType;
+
+use base qw(Koha::Objects);
+
+=head1 NAME
+
+Koha::RestrictionTypes - Koha Restriction Types Object set class
+
+=head1 API
+
+=head2 Class Methods
+
+=cut
+
+=head3 type
+
+Return all restriction types as a hashref keyed on the code
+
+=cut
+
+sub keyed_on_code {
+    my ( $self ) = @_;
+
+    my @all = $self->_resultset()->search();
+    my $out = {};
+    for my $r( @all ) {
+        my %col = $r->get_columns;
+        $out->{$r->code} = \%col;
+    }
+    return $out;
+}
+
+=head3 type
+
+=cut
+
+sub _type {
+    return 'DebarmentType';
+}
+
+=head3 type
+
+Object class
+
+=cut
+
+sub object_class {
+    return 'Koha::RestrictionType';
+}
+
+1;
-- 
2.20.1