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 |