Bug 33340: Correct formatting of English 1-page order PDF when it covers multiple...
[koha.git] / Koha / Illrequest / SupplierUpdate.pm
1 package Koha::Illrequest::SupplierUpdate;
2
3 # Copyright 2022 PTFS Europe Ltd
4 #
5 # This file is part of Koha.
6 #
7 # Koha is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
11 #
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20 use Modern::Perl;
21
22 =head1 NAME
23
24 Koha::Illrequest::SupplierUpdate - Represents a single request update from a supplier
25
26 =head1 SYNOPSIS
27
28 Object-oriented class that provides an object allowing us to interact with
29 an update from a supplier
30
31 =head1 DESCRIPTION
32
33 Object-oriented class that provides an object allowing us to interact with
34 an update from a supplier
35
36 =head1 API
37
38 =head2 Class Methods
39
40 =head3 new
41
42     my $update = Koha::Illrequest::SupplierUpdate->new(
43         $source_type,
44         $source_name,
45         $update
46     );
47
48 Create a new Koha::Illrequest::SupplierUpdate object.
49
50 =cut
51
52 sub new {
53     my ( $class, $source_type, $source_name, $update, $request ) = @_;
54     my $self  = {};
55
56     $self->{source_type} = $source_type;
57     $self->{source_name} = $source_name;
58     $self->{update} = $update;
59     $self->{request} = $request;
60     $self->{processors} = [];
61
62     bless $self, $class;
63
64     return $self;
65 }
66
67 =head3 attach_processor
68
69     Koha::Illrequest::SupplierUpdate->attach_processor($processor);
70
71 Pushes a processor function onto the 'processors' arrayref
72
73 =cut
74
75 sub attach_processor {
76     my ( $self, $processor ) = @_;
77     push(@{$self->{processors}}, $processor);
78 }
79
80 =head3 run_processors
81
82     Koha::Illrequest::SupplierUpdate->run_processors();
83
84 Iterates all processors on this object and runs each
85
86 =cut
87
88 sub run_processors {
89     my ( $self, $options ) = @_;
90     my $results = [];
91     foreach my $processor(@{$self->{processors}}) {
92         my $processor_result = {
93             name   => $processor->{name},
94             result => {
95                 success => [],
96                 error   => []
97             }
98         };
99         $processor->run($self, $options, $processor_result->{result});
100         push @{$results}, $processor_result;
101     }
102     return $results;
103 }
104
105 =head1 AUTHOR
106
107 Andrew Isherwood <andrew.isherwood@ptfs-europe.com>
108
109 =cut
110
111 1;