View | Details | Raw Unified | Return to bug 37389
Collapse All | Expand All

(-)a/Koha/ILL/Request.pm (-31 lines)
Lines 2220-2256 sub get_staff_table_actions { Link Here
2220
    return $ill_table_actions;
2220
    return $ill_table_actions;
2221
}
2221
}
2222
2222
2223
=head3 AUTOLOAD
2224
2225
=cut
2226
2227
our $AUTOLOAD;
2228
2229
sub AUTOLOAD {
2230
    my ($self) = @_;
2231
2232
    my $name = $AUTOLOAD;
2233
    $name =~ s/.*:://;    # Remove package name
2234
2235
    if ( $name =~ /^extended_attributes_(\w+)$/ ) {
2236
        my $type = $1;
2237
2238
        # Define the method dynamically
2239
        no strict 'refs';
2240
        *{$AUTOLOAD} = sub {
2241
            my ($self)   = @_;
2242
            my $relation = 'extended_attributes_' . $type;
2243
            my $rs       = $self->_result->$relation;
2244
            return Koha::ILL::Request::Attributes->_new_from_dbic($rs)->search;
2245
        };
2246
2247
        # Call the newly defined method
2248
        return $self->$name();
2249
    }
2250
    my $wt = 'SUPER::'.$name;
2251
    return $self->$wt;
2252
}
2253
2254
sub get_column(){
2223
sub get_column(){
2255
    my ($self, $column_name) = @_;
2224
    my ($self, $column_name) = @_;
2256
    return $self->_result->get_column($column_name);
2225
    return $self->_result->get_column($column_name);
(-)a/Koha/Object/Mixin/ExtendedAttributes.pm (-1 / +64 lines)
Line 0 Link Here
0
- 
1
package Koha::Object::Mixin::ExtendedAttributes;
2
3
# Copyright 2024 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::Object::Mixin::ExtendedAttributes
25
26
=head2 Class methods
27
28
29
=head3 AUTOLOAD
30
31
=cut
32
33
our $AUTOLOAD;
34
35
# This class is not yet utilized, but we'll need it if we ever want to support this sort of syntax:
36
# ill_request->extended_attributes_author; and get the 'author' extended_attributes from the ill_request
37
# TODO: This needs to be abstracted in the future, currently only considering ILL
38
39
sub AUTOLOAD {
40
    my ($self) = @_;
41
42
    my $name = $AUTOLOAD;
43
    $name =~ s/.*:://;    # Remove package name
44
45
    if ( $name =~ /^extended_attributes_(\w+)$/ ) {
46
        my $type = $1;
47
48
        # Define the method dynamically
49
        no strict 'refs';
50
        *{$AUTOLOAD} = sub {
51
            my ($self)   = @_;
52
            my $relation = 'extended_attributes_' . $type;
53
            my $rs       = $self->_result->$relation;
54
            return Koha::ILL::Request::Attributes->_new_from_dbic($rs)->search;
55
        };
56
57
        # Call the newly defined method
58
        return $self->$name();
59
    }
60
    my $wt = 'SUPER::' . $name;
61
    return $self->$wt;
62
}
63
64
1;

Return to bug 37389