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

(-)a/Koha/ILL/Requests.pm (-20 / +5 lines)
Lines 120-137 Returns a list of relation accessor names. Link Here
120
=cut
120
=cut
121
121
122
sub _build_extended_attributes_relations {
122
sub _build_extended_attributes_relations {
123
    my ($self) = @_;
123
    my ( $self, $types ) = @_;
124
125
    my @distinct_types = Koha::ILL::Request::Attributes->_resultset->search(
126
        {},    # No specific conditions
127
        {
128
            select   => ['type'],
129
            group_by => ['type']
130
        }
131
    )->get_column('type')->all;
132
124
133
    for my $type (@distinct_types) {
125
    my $result_source = $self->_resultset->result_source;
134
        my $test = $self->_resultset->_result_class->has_many(
126
    for my $type ( @{$types} ) {
127
        $result_source->add_relationship(
135
            "extended_attributes_$type",
128
            "extended_attributes_$type",
136
            "Koha::Schema::Result::Illrequestattribute",
129
            "Koha::Schema::Result::Illrequestattribute",
137
            sub {
130
            sub {
Lines 145-160 sub _build_extended_attributes_relations { Link Here
145
            { cascade_copy => 0, cascade_delete => 0 },
138
            { cascade_copy => 0, cascade_delete => 0 },
146
        );
139
        );
147
140
148
        my $schema = $self->_resultset->result_source->schema;
149
150
        $schema->unregister_source('Koha::Schema::Result::Illrequest');
151
        $schema->register_class( 'Koha::Schema::Result::Illrequest', $test );
152
153
        # Testing to check if the dynamically added method has been aded. It's not been!!
154
        $self->find(1)->extended_attributes_article_title;
155
    }
141
    }
156
142
    return map { 'extended_attributes_' . $_ } @{$types};
157
    return map { 'extended_attributes_'.$_ } @distinct_types;
158
}
143
}
159
144
160
=head3 _type
145
=head3 _type
(-)a/Koha/REST/Plugin/Query.pm (-3 / +3 lines)
Lines 181-191 Generates the DBIC join attribute based on extended_attributes query entries, an Link Here
181
            {
181
            {
182
                # my $ea_entries = $self->_get_extended_attributes_entries( $filtered_params, 0 );
182
                # my $ea_entries = $self->_get_extended_attributes_entries( $filtered_params, 0 );
183
183
184
                my @types = qw( article_title issue volume );
185
184
                # Calling our private method to build the extended attributes relations
186
                # Calling our private method to build the extended attributes relations
185
                $result_set->_build_extended_attributes_relations();
187
                my @test = $result_set->_build_extended_attributes_relations(\@types);
186
188
187
                # Testing out the extended attributes join (hardcoded for now)
189
                # Testing out the extended attributes join (hardcoded for now)
188
                my @test = qw( extended_attributes_article_title extended_attributes_issue extended_attributes_volume );
189
                foreach my $test (@test) {
190
                foreach my $test (@test) {
190
                    push( @{ $attributes->{join} }, $test );
191
                    push( @{ $attributes->{join} }, $test );
191
                }
192
                }
192
- 

Return to bug 37389