|
Lines 293-298
sub _numeric_column_type {
Link Here
|
| 293 |
return ( grep { $column_type eq $_ } @numeric_types) ? 1 : 0; |
293 |
return ( grep { $column_type eq $_ } @numeric_types) ? 1 : 0; |
| 294 |
} |
294 |
} |
| 295 |
|
295 |
|
|
|
296 |
=head3 $object->unblessed_all_relateds |
| 297 |
|
| 298 |
my $everything_into_one_hashref = $object->unblessed_all_relateds |
| 299 |
|
| 300 |
The unblessed method only retrieves column' values for the column of the object. |
| 301 |
In a *few* cases we want to retrieve the information of all the prefetched data. |
| 302 |
|
| 303 |
=cut |
| 304 |
|
| 305 |
sub unblessed_all_relateds { |
| 306 |
my ($self) = @_; |
| 307 |
|
| 308 |
my %data; |
| 309 |
my $related_resultsets = $self->_result->{related_resultsets} || {}; |
| 310 |
my $rs = $self; |
| 311 |
while ( $related_resultsets and %$related_resultsets ) { |
| 312 |
my @relations = keys %{ $related_resultsets }; |
| 313 |
if ( @relations ) { |
| 314 |
my $relation = $relations[0]; |
| 315 |
$rs = $rs->related_resultset($relation)->get_cache; |
| 316 |
$rs = $rs->[0]; # Does it makes sense to have several values here? |
| 317 |
my $object_class = Koha::Object::_get_object_class( $rs->result_class ); |
| 318 |
my $koha_object = $object_class->_new_from_dbic( $rs ); |
| 319 |
$related_resultsets = $rs->{related_resultsets}; |
| 320 |
%data = ( %data, %{ $koha_object->unblessed } ); |
| 321 |
} |
| 322 |
} |
| 323 |
%data = ( %data, %{ $self->unblessed } ); |
| 324 |
return \%data; |
| 325 |
} |
| 326 |
|
| 296 |
=head3 $object->_result(); |
327 |
=head3 $object->_result(); |
| 297 |
|
328 |
|
| 298 |
Returns the internal DBIC Row object |
329 |
Returns the internal DBIC Row object |
|
Lines 324-329
sub _columns {
Link Here
|
| 324 |
return $self->{_columns}; |
355 |
return $self->{_columns}; |
| 325 |
} |
356 |
} |
| 326 |
|
357 |
|
|
|
358 |
sub _get_object_class { |
| 359 |
my ( $type ) = @_; |
| 360 |
return unless $type; |
| 361 |
|
| 362 |
if( $type->can('koha_object_class') ) { |
| 363 |
return $type->koha_object_class; |
| 364 |
} |
| 365 |
$type =~ s|Schema::Result::||; |
| 366 |
return ${type}; |
| 367 |
} |
| 368 |
|
| 327 |
=head3 AUTOLOAD |
369 |
=head3 AUTOLOAD |
| 328 |
|
370 |
|
| 329 |
The autoload method is used only to get and set values for an objects properties. |
371 |
The autoload method is used only to get and set values for an objects properties. |
|
Lines 348-354
sub AUTOLOAD {
Link Here
|
| 348 |
} |
390 |
} |
| 349 |
} |
391 |
} |
| 350 |
|
392 |
|
| 351 |
my @known_methods = qw( is_changed id in_storage get_column discard_changes update ); |
393 |
my @known_methods = qw( is_changed id in_storage get_column discard_changes update related_resultset ); |
|
|
394 |
|
| 352 |
Koha::Exceptions::Object::MethodNotCoveredByTests->throw( "The method $method is not covered by tests!" ) unless grep {/^$method$/} @known_methods; |
395 |
Koha::Exceptions::Object::MethodNotCoveredByTests->throw( "The method $method is not covered by tests!" ) unless grep {/^$method$/} @known_methods; |
| 353 |
|
396 |
|
| 354 |
my $r = eval { $self->_result->$method(@_) }; |
397 |
my $r = eval { $self->_result->$method(@_) }; |
| 355 |
- |
|
|