Lines 119-161
Returns a list of relation accessor names.
Link Here
|
119 |
|
119 |
|
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 |
|
124 |
|
125 |
# my @distinct_types = Koha::ILL::Request::Attributes->_resultset->search( |
125 |
my $result_source = $self->_resultset->result_source; |
126 |
# {}, # No specific conditions |
126 |
for my $type ( @{$types} ) { |
127 |
# { |
127 |
$result_source->add_relationship( |
128 |
# select => ['type'], |
128 |
"extended_attributes_$type", |
129 |
# group_by => ['type'] |
129 |
"Koha::Schema::Result::Illrequestattribute", |
130 |
# } |
130 |
sub { |
131 |
# )->get_column('type')->all; |
131 |
my $args = shift; |
132 |
|
132 |
|
133 |
# for my $type (@distinct_types) { |
133 |
return { |
134 |
# my $test = $self->_resultset->_result_class->has_many( |
134 |
"$args->{foreign_alias}.illrequest_id" => { -ident => "$args->{self_alias}.illrequest_id" }, |
135 |
# "extended_attributes_$type", |
135 |
"$args->{foreign_alias}.type" => { '=', $type }, |
136 |
# "Koha::Schema::Result::Illrequestattribute", |
136 |
}; |
137 |
# sub { |
137 |
}, |
138 |
# my $args = shift; |
138 |
{ cascade_copy => 0, cascade_delete => 0 }, |
139 |
|
139 |
); |
140 |
# return { |
140 |
|
141 |
# "$args->{foreign_alias}.illrequest_id" => { -ident => "$args->{self_alias}.illrequest_id" }, |
141 |
} |
142 |
# "$args->{foreign_alias}.type" => { '=', $type }, |
142 |
return map { 'extended_attributes_' . $_ } @{$types}; |
143 |
# }; |
143 |
} |
144 |
# }, |
|
|
145 |
# { cascade_copy => 0, cascade_delete => 0 }, |
146 |
# ); |
147 |
|
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 |
# } |
156 |
|
157 |
# return map { 'extended_attributes_'.$_ } @distinct_types; |
158 |
# } |
159 |
|
144 |
|
160 |
=head3 _type |
145 |
=head3 _type |
161 |
|
146 |
|