Bugzilla – Attachment 43130 Details for
Bug 12478
Elasticsearch support for Koha
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 12478: Remove Koha::ItemType[s] Class::Accessor classes
Bug-12478-Remove-KohaItemTypes-ClassAccessor-class.patch (text/plain), 5.70 KB, created by
Jonathan Druart
on 2015-10-05 13:42:17 UTC
(
hide
)
Description:
Bug 12478: Remove Koha::ItemType[s] Class::Accessor classes
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2015-10-05 13:42:17 UTC
Size:
5.70 KB
patch
obsolete
>From bce11d34518fe5ccdc72e34758c701d4eba958d6 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 5 Oct 2015 11:54:59 +0100 >Subject: [PATCH] Bug 12478: Remove Koha::ItemType[s] Class::Accessor classes > >--- > Koha/ItemType.pm | 70 --------------------------------- > Koha/ItemTypes.pm | 113 ------------------------------------------------------ > 2 files changed, 183 deletions(-) > delete mode 100644 Koha/ItemType.pm > delete mode 100644 Koha/ItemTypes.pm > >diff --git a/Koha/ItemType.pm b/Koha/ItemType.pm >deleted file mode 100644 >index f2bfd6f..0000000 >--- a/Koha/ItemType.pm >+++ /dev/null >@@ -1,70 +0,0 @@ >-package Koha::ItemType; >- >-# This represents a single itemtype >- >-# Copyright 2014 Catalyst IT >-# >-# 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. >- >-=head1 NAME >- >-Koha::ItemType - represents a single itemtype >- >-=head1 DESCRIPTION >- >-This contains the data relating to a single itemtype >- >-=head1 SYNOPSIS >- >- use Koha::ItemTypes; >- my $types = Koha::ItemTypes->new(); >- my $type = $types->get_itemtype('CODE'); >- print $type->code, $type->description, $type->rentalcharge, >- $type->imageurl, $type->summary, $type->checkinmsg, >- $type->checkinmsgtype; >- >-Creating an instance of C<Koha::ItemType> without using L<Koha::ItemTypes> >-can be done simply by passing a hashref containing the values to C<new()>. >-Note when doing this that a value for C<itemtype> will become a value for >-C<code>. >- >-=head1 FUNCTIONS >- >-In addition to the read-only accessors mentioned above, the following functions >-exist. >- >-=cut >- >-use Modern::Perl; >- >-use base qw(Class::Accessor); >- >-# TODO can we make these auto-generate from the input hash so it doesn't >-# have to be updated when the database is? >-__PACKAGE__->mk_ro_accessors( >- qw(code description rentalcharge imageurl >- summary checkinmsg checkinmsgtype) >-); >- >-sub new { >- my $class = shift @_; >- >- my %data = ( %{ $_[0] }, code => $_[0]->{itemtype} ); >- my $self = $class->SUPER::new( \%data ); >- return $self; >-} >- >-1; >diff --git a/Koha/ItemTypes.pm b/Koha/ItemTypes.pm >deleted file mode 100644 >index 9cf0b37..0000000 >--- a/Koha/ItemTypes.pm >+++ /dev/null >@@ -1,113 +0,0 @@ >-package Koha::ItemTypes; >- >-# This contains the item types that the system knows about. >- >-# Copyright 2014 Catalyst IT >-# >-# 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. >- >-=head1 NAME >- >-Koha::ItemTypes - handles the item types that Koha knows about >- >-=head1 DESCRIPTION >- >-This contains functions to access the item types. >- >-Note that any changes that happen to the database while this object is live >-may not be reflected, so best don't hold onto it for a long time >- >-=cut >- >-use Koha::Database; >-use Koha::ItemType; >-use Modern::Perl; >- >-use Data::Dumper; # TODO remove >-use base qw(Class::Accessor); >- >-__PACKAGE__->mk_accessors(qw()); >- >-=head1 FUNCTIONS >- >-=head2 new >- >- my $itypes = Koha::ItemTypes->new(); >- >-Creates a new instance of the object. >- >-=cut >- >-# Handled by Class::Accessor >- >-=head2 get_itemtype >- >- my @itype = $itypes->get_itemtype('CODE1', 'CODE2'); >- >-This returns a L<Koha::ItemType> object for each of the provided codes. For >-any that don't exist, an C<undef> is returned. >- >-=cut >- >-sub get_itemtype { >- my ($self, @codes) = @_; >- >- my $schema = Koha::Database->new()->schema(); >- my @res; >- >- foreach my $c (@codes) { >- if (exists $self->{cached}{$c}) { >- push @res, $self->{cached}{$c}; >- next; >- } >- my $rs = $schema->resultset('Itemtype')->search( { itemtype => $c } ); >- my $r = $rs->next; >- if (!$r) { >- push @res, undef; >- next; >- } >- my %data = $r->get_inflated_columns; >- my $it = Koha::ItemType->new(\%data); >- push @res, $it; >- $self->{cached}{$c} = $it; >- } >- if (wantarray) { >- return @res; >- } else { >- return @res ? $res[0] : undef; >- } >-} >- >-=head2 get_description_for_code >- >- my $desc = $itypes->get_description_for_code($code); >- >-This returns the description for an itemtype code. As a special case, if >-there is no itemtype for this code, it'll return what it was given. >- >-It is mostly as a convenience function rather than using L<get_itemtype>. >- >-=cut >- >-sub get_description_for_code { >- my ($self, $code) = @_; >- >- my $itype = $self->get_itemtype($code); >- return $code if !$itype; >- return $itype->description; >-} >- >-1; >-- >2.1.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 12478
:
29204
|
31128
|
31129
|
33136
|
33137
|
33138
|
33139
|
33140
|
33141
|
35654
|
40903
|
42030
|
42031
|
42032
|
42033
|
42062
|
42063
|
42064
|
42065
|
42066
|
42067
|
42068
|
42069
|
42392
|
42393
|
43127
|
43128
|
43129
|
43130
|
43131
|
43132
|
43133
|
43134
|
43140
|
43141
|
43142
|
43148
|
43345
|
43346
|
43347
|
43348
|
43349
|
43350
|
43351
|
43352
|
43373
|
47767
|
47768
|
50115
|
50159
|
50211
|
50212
|
50213
|
50214
|
50245
|
50246
|
50291
|
50292