@@ -, +, @@ 601 my $syspref = Koha::Config::SysPrefs->find( $var ); 602 my $type = $syspref ? $syspref->type() : undef; 603 604 $value = 0 if ( $type && $type eq 'YesNo' && $value eq '' ); --- Koha/AudioAlert.pm | 2 +- Koha/AudioAlerts.pm | 2 +- Koha/AuthorisedValue.pm | 2 +- Koha/AuthorisedValues.pm | 2 +- Koha/Biblio.pm | 2 +- Koha/Biblioitem.pm | 2 +- Koha/Biblioitems.pm | 2 +- Koha/Biblios.pm | 2 +- Koha/Borrower.pm | 2 +- Koha/Borrowers.pm | 2 +- Koha/Branch.pm | 2 +- Koha/Branches.pm | 2 +- Koha/Cities.pm | 2 +- Koha/City.pm | 2 +- Koha/Config/SysPref.pm | 2 +- Koha/Config/SysPrefs.pm | 2 +- Koha/Hold.pm | 2 +- Koha/Holds.pm | 2 +- Koha/Item.pm | 2 +- Koha/Items.pm | 2 +- Koha/Localization.pm | 2 +- Koha/Localizations.pm | 2 +- Koha/Object.pm | 22 +++++++++++----------- Koha/Objects.pm | 14 ++++++-------- Koha/Patron/Categories.pm | 2 +- Koha/Patron/Category.pm | 2 +- Koha/Virtualshelf.pm | 2 +- Koha/Virtualshelfcontent.pm | 2 +- Koha/Virtualshelfcontents.pm | 2 +- Koha/Virtualshelfshare.pm | 2 +- Koha/Virtualshelfshares.pm | 2 +- Koha/Virtualshelves.pm | 2 +- 32 files changed, 47 insertions(+), 49 deletions(-) --- a/Koha/AudioAlert.pm +++ a/Koha/AudioAlert.pm @@ -66,7 +66,7 @@ sub move { =cut -sub type { +sub _type { return 'AudioAlert'; } --- a/Koha/AudioAlerts.pm +++ a/Koha/AudioAlerts.pm @@ -136,7 +136,7 @@ sub fix_precedences { =cut -sub type { +sub _type { return 'AudioAlert'; } --- a/Koha/AuthorisedValue.pm +++ a/Koha/AuthorisedValue.pm @@ -164,7 +164,7 @@ sub _avb_resultset { =cut -sub type { +sub _type { return 'AuthorisedValue'; } --- a/Koha/AuthorisedValues.pm +++ a/Koha/AuthorisedValues.pm @@ -79,7 +79,7 @@ sub categories { =cut -sub type { +sub _type { return 'AuthorisedValue'; } --- a/Koha/Biblio.pm +++ a/Koha/Biblio.pm @@ -39,7 +39,7 @@ Koha::Biblio - Koha Biblio Object class =cut -sub type { +sub _type { return 'Biblio'; } --- a/Koha/Biblioitem.pm +++ a/Koha/Biblioitem.pm @@ -37,7 +37,7 @@ Koha::Biblioitem - Koha Biblioitem Object class =cut -sub type { +sub _type { return 'Biblioitem'; } --- a/Koha/Biblioitems.pm +++ a/Koha/Biblioitems.pm @@ -39,7 +39,7 @@ Koha::Biblioitem - Koha Biblioitem Object class =cut -sub type { +sub _type { return 'Biblioitem'; } --- a/Koha/Biblios.pm +++ a/Koha/Biblios.pm @@ -41,7 +41,7 @@ Koha::Biblios - Koha Biblio object set class =cut -sub type { +sub _type { return 'Biblio'; } --- a/Koha/Borrower.pm +++ a/Koha/Borrower.pm @@ -39,7 +39,7 @@ Koha::Borrower - Koha Borrower Object class =cut -sub type { +sub _type { return 'Borrower'; } --- a/Koha/Borrowers.pm +++ a/Koha/Borrowers.pm @@ -41,7 +41,7 @@ Koha::Borrower - Koha Borrower Object class =cut -sub type { +sub _type { return 'Borrower'; } --- a/Koha/Branch.pm +++ a/Koha/Branch.pm @@ -39,7 +39,7 @@ Koha::Branch - Koha Branch object class =cut -sub type { +sub _type { return 'Branch'; } --- a/Koha/Branches.pm +++ a/Koha/Branches.pm @@ -41,7 +41,7 @@ Koha::Branches - Koha Branch object set class =cut -sub type { +sub _type { return 'Branch'; } --- a/Koha/Cities.pm +++ a/Koha/Cities.pm @@ -39,7 +39,7 @@ Koha::Cities - Koha City Object set class =cut -sub type { +sub _type { return 'City'; } --- a/Koha/City.pm +++ a/Koha/City.pm @@ -37,7 +37,7 @@ Koha::City - Koha City Object class =cut -sub type { +sub _type { return 'City'; } --- a/Koha/Config/SysPref.pm +++ a/Koha/Config/SysPref.pm @@ -39,7 +39,7 @@ Koha::Config::SysPref - Koha System Preference Object class =cut -sub type { +sub _type { return 'Systempreference'; } --- a/Koha/Config/SysPrefs.pm +++ a/Koha/Config/SysPrefs.pm @@ -41,7 +41,7 @@ Koha::Config::SysPrefs - Koha System Preference object set class =cut -sub type { +sub _type { return 'Systempreference'; } --- a/Koha/Hold.pm +++ a/Koha/Hold.pm @@ -165,7 +165,7 @@ sub borrower { =cut -sub type { +sub _type { return 'Reserve'; } --- a/Koha/Holds.pm +++ a/Koha/Holds.pm @@ -53,7 +53,7 @@ sub waiting { =cut -sub type { +sub _type { return 'Reserve'; } --- a/Koha/Item.pm +++ a/Koha/Item.pm @@ -78,7 +78,7 @@ sub holding_branch { =cut -sub type { +sub _type { return 'Item'; } --- a/Koha/Items.pm +++ a/Koha/Items.pm @@ -41,7 +41,7 @@ Koha::Items - Koha Item object set class =cut -sub type { +sub _type { return 'Item'; } --- a/Koha/Localization.pm +++ a/Koha/Localization.pm @@ -21,7 +21,7 @@ use Koha::Database; use base qw(Koha::Object); -sub type { +sub _type { return 'Localization'; } --- a/Koha/Localizations.pm +++ a/Koha/Localizations.pm @@ -23,7 +23,7 @@ use Koha::Localization; use base qw(Koha::Objects); -sub type { +sub _type { return 'Localization'; } --- a/Koha/Object.pm +++ a/Koha/Object.pm @@ -57,12 +57,12 @@ sub new { if ($attributes) { $self->{_result} = - Koha::Database->new()->schema()->resultset( $class->type() ) + Koha::Database->new()->schema()->resultset( $class->_type() ) ->new($attributes); } - croak("No type found! Koha::Object must be subclassed!") - unless $class->type(); + croak("No _type found! Koha::Object must be subclassed!") + unless $class->_type(); bless( $self, $class ); @@ -81,11 +81,11 @@ sub _new_from_dbic { # DBIC result row $self->{_result} = $dbic_row; - croak("No type found! Koha::Object must be subclassed!") - unless $class->type(); + croak("No _type found! Koha::Object must be subclassed!") + unless $class->_type(); - croak( "DBIC result type " . ref( $self->{_result} ) . " isn't of the type " . $class->type() ) - unless ref( $self->{_result} ) eq "Koha::Schema::Result::" . $class->type(); + croak( "DBIC result _type " . ref( $self->{_result} ) . " isn't of the _type " . $class->_type() ) + unless ref( $self->{_result} ) eq "Koha::Schema::Result::" . $class->_type(); bless( $self, $class ); @@ -230,7 +230,7 @@ sub _result { # If we don't have a dbic row at this point, we need to create an empty one $self->{_result} ||= - Koha::Database->new()->schema()->resultset( $self->type() )->new({}); + Koha::Database->new()->schema()->resultset( $self->_type() )->new({}); return $self->{_result}; } @@ -279,14 +279,14 @@ sub AUTOLOAD { return; } -=head3 type +=head3 _type This method must be defined in the child class. The value is the name of the DBIC resultset. -For example, for borrowers, the type method will return "Borrower". +For example, for borrowers, the _type method will return "Borrower". =cut -sub type { } +sub _type { } sub DESTROY { } --- a/Koha/Objects.pm +++ a/Koha/Objects.pm @@ -23,8 +23,6 @@ use Carp; use Koha::Database; -our $type; - =head1 NAME Koha::Objects - Koha Object set base class @@ -229,24 +227,24 @@ sub _resultset { if ( ref($self) ) { $self->{_resultset} ||= - Koha::Database->new()->schema()->resultset( $self->type() ); + Koha::Database->new()->schema()->resultset( $self->_type() ); return $self->{_resultset}; } else { - return Koha::Database->new()->schema()->resultset( $self->type() ); + return Koha::Database->new()->schema()->resultset( $self->_type() ); } } -=head3 type +=head3 _type -The type method must be set for all child classes. +The _type method must be set for all child classes. The value returned by it should be the DBIC resultset name. -For example, for holds, type should return 'Reserve'. +For example, for holds, _type should return 'Reserve'. =cut -sub type { } +sub _type { } =head3 object_class --- a/Koha/Patron/Categories.pm +++ a/Koha/Patron/Categories.pm @@ -39,7 +39,7 @@ Koha::Patron::Categories - Koha Patron Category Object set class =cut -sub type { +sub _type { return 'Category'; } --- a/Koha/Patron/Category.pm +++ a/Koha/Patron/Category.pm @@ -181,7 +181,7 @@ sub _catb_resultset { =cut -sub type { +sub _type { return 'Category'; } --- a/Koha/Virtualshelf.pm +++ a/Koha/Virtualshelf.pm @@ -273,7 +273,7 @@ sub can_biblios_be_removed { return 0; } -sub type { +sub _type { return 'Virtualshelve'; } --- a/Koha/Virtualshelfcontent.pm +++ a/Koha/Virtualshelfcontent.pm @@ -38,7 +38,7 @@ Koha::Virtualshelfcontent - Koha Virtualshelfcontent Object class =cut -sub type { +sub _type { return 'Virtualshelfcontent'; } --- a/Koha/Virtualshelfcontents.pm +++ a/Koha/Virtualshelfcontents.pm @@ -39,7 +39,7 @@ Koha::Virtualshelfcontents - Koha Virtualshelfcontents Object class =cut -sub type { +sub _type { return 'Virtualshelfcontent'; } --- a/Koha/Virtualshelfshare.pm +++ a/Koha/Virtualshelfshare.pm @@ -67,7 +67,7 @@ sub has_expired { return $has_expired == 1 ? 1 : 0 } -sub type { +sub _type { return 'Virtualshelfshare'; } --- a/Koha/Virtualshelfshares.pm +++ a/Koha/Virtualshelfshares.pm @@ -39,7 +39,7 @@ Koha::Virtualshelfshares - Koha Virtualshelfshares Object class =cut -sub type { +sub _type { return 'Virtualshelfshare'; } --- a/Koha/Virtualshelves.pm +++ a/Koha/Virtualshelves.pm @@ -119,7 +119,7 @@ sub get_some_shelves { ); } -sub type { +sub _type { return 'Virtualshelve'; } --