Ignore:
Timestamp:
06/19/19 20:02:16 (5 years ago)
Author:
nanardon
Message:

Add a way to dump object and all related objects

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/objects.pm

    r2266 r2267  
    313313 
    314314sub ParentObject { } 
     315 
     316=head2 ListChildObjects 
     317 
     318Return objects having this object as Parent 
     319 
     320=cut 
     321 
     322sub ListChildObjects { 
     323    my ($self) = @_; 
     324 
     325    my $Subotype = $self->GetOtypeDef or return; 
     326 
     327    my %res; 
     328 
     329    foreach my $otype (keys %$Subotype) { 
     330        foreach my $attr (ref $Subotype->{$otype} ? @{ $Subotype->{$otype} } : $Subotype->{$otype}) { 
     331            my @list = $self->base->search_objects( $otype, $attr . '=' . $self->id ); 
     332            if (@list) { 
     333                push(@{ $res{$otype} }, @list); 
     334            } 
     335        } 
     336    } 
     337 
     338    %res; 
     339} 
    315340 
    316341sub _get_ikey { 
Note: See TracChangeset for help on using the changeset viewer.