|
Line 0
Link Here
|
| 0 |
- |
1 |
package Koha::Plugin::TestItemBarcodeTransform; |
|
|
2 |
|
| 3 |
## It's good practice to use Modern::Perl |
| 4 |
use Modern::Perl; |
| 5 |
|
| 6 |
use Koha::Exceptions::Exception; |
| 7 |
use Koha::Plugins::Tab; |
| 8 |
|
| 9 |
use Mojo::JSON qw( decode_json ); |
| 10 |
|
| 11 |
## Required for all plugins |
| 12 |
use base qw(Koha::Plugins::Base); |
| 13 |
|
| 14 |
our $VERSION = 1.01; |
| 15 |
our $metadata = { |
| 16 |
name => 'Test Plugin for item_barcode_transform', |
| 17 |
author => 'Kyle M Hall', |
| 18 |
description => 'Test plugin', |
| 19 |
date_authored => '2021-10-14', |
| 20 |
date_updated => '2021-10-14', |
| 21 |
minimum_version => '21.11', |
| 22 |
maximum_version => undef, |
| 23 |
version => $VERSION, |
| 24 |
}; |
| 25 |
|
| 26 |
## This is the minimum code required for a plugin's 'new' method |
| 27 |
## More can be added, but none should be removed |
| 28 |
sub new { |
| 29 |
my ( $class, $args ) = @_; |
| 30 |
$args->{'metadata'} = $metadata; |
| 31 |
my $self = $class->SUPER::new($args); |
| 32 |
return $self; |
| 33 |
} |
| 34 |
|
| 35 |
sub item_barcode_transform { |
| 36 |
my ( $self, $barcode ) = @_; |
| 37 |
my $param = $$barcode; |
| 38 |
if ( Scalar::Util::looks_like_number( $$barcode ) ) { |
| 39 |
$$barcode = $$barcode * 4 |
| 40 |
} |
| 41 |
Koha::Exceptions::Exception->throw("item_barcode_transform called with parameter: $param"); |
| 42 |
} |
| 43 |
|
| 44 |
1; |