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

(-)a/Koha/ILL/Requests.pm (-1 / +41 lines)
Lines 108-113 sub search_incomplete { Link Here
108
108
109
=head2 Internal methods
109
=head2 Internal methods
110
110
111
112
=head3 _build_extended_attributes_relations
113
114
Method to dynamically add has_many relations for each ILLRequestAttribute type stored in the ILLRequestAttributes table.
115
116
Used in the API to allow for advanced joins.
117
118
Returns a list of relation accessor names.
119
120
=cut
121
122
sub _build_extended_attributes_relations {
123
    my ($self) = @_;
124
125
    my @distinct_types = $self->_resultset->search(
126
        {},    # No specific conditions
127
        {
128
            select   => ['type'],
129
            distinct => 1,
130
        }
131
    )->get_column('type')->all;
132
133
    for my $type (@distinct_types) {
134
        $self->_resultset->has_many(
135
            "extended_attributes_$type",
136
            "Koha::Schema::Result::Illrequestattribute",
137
            sub {
138
                my $args = shift;
139
140
                return {
141
                    "$args->{foreign_alias}.illrequest_id" => { -ident => "$args->{self_alias}.illrequest_id" },
142
                    "$args->{foreign_alias}.type"          => { '=', $type },
143
                };
144
            },
145
            { cascade_copy => 0, cascade_delete => 0 },
146
        );
147
    }
148
149
    return map { 'extended_attributes_'.$_ } @distinct_types;
150
}
151
111
=head3 _type
152
=head3 _type
112
153
113
=cut
154
=cut
114
- 

Return to bug 37389