ORDER BY ${wanted}_table, ${wanted}_id, depth ASC;
my $links = selectall_hashref_query($::form, $::form->get_standard_dbh, $query, $self->id, $self->meta->table);
+
+ return [] unless @$links;
+
my $link_objs = SL::DB::Manager::RecordLink->get_all(query => [ id => [ map { $_->{id} } @$links ] ]);
my @objects = map { $get_objects->($_) } @$link_objs;
if ($params{save_path}) {
my %links_by_id = map { $_->{id} => $_ } @$links;
for (@objects) {
- $_->{_record_link_path} = $links_by_id{$_->{_record_link}->id}->{path};
- $_->{_record_link_depth} = $links_by_id{$_->{_record_link}->id}->{depth};
+ my $link = $links_by_id{$_->{_record_link}->id};
+ my $intermediate_links = SL::DB::Manager::RecordLink->get_all(query => [ id => $link->{path} ]);
+ $_->{_record_link_path} = $link->{path};
+ $_->{_record_link_obj_path} = [ map { $get_objects->($_) } @$intermediate_links ];
+ $_->{_record_link_depth} = $link->{depth};
}
}
names will be returned.
If no parameter C<direction> is given, but any of C<to>, C<from> or C<both>,
-then C<direction> is infered accordingly. If neither are given, C<direction> is
+then C<direction> is inferred accordingly. If neither are given, C<direction> is
set to C<both>.
The optional parameter C<via> can be used to retrieve all documents that may
Examples:
If you only need invoices created directly from an order C<$order> (no
-delivery orders inbetween) then the call could look like this:
+delivery orders in between) then the call could look like this:
my $invoices = $order->linked_records(
direction => 'to',
);
Retrieving all invoices from a quotation no matter whether or not
-orders or delivery orders where created:
+orders or delivery orders were created:
my $invoices = $quotation->linked_records(
direction => 'to',
will find the path o1 -> o2 -> do -> o2 -> i without considering it a cycle.
-The optional extra flag C<save_path> will give you extra inforamtion saved in
+The optional extra flag C<save_path> will give you extra information saved in
the returned objects:
my $records = $order->linked_records(
=item C<_record_link_path>
-And array with the ids of the visited links. The shortest paths will be
-prefered, so in the previous example this would contain the ids of o1-o2 and
+An array with the ids of the visited links. The shortest paths will be
+preferred, so in the previous example this would contain the ids of o1-o2 and
o2-i.
=item C<_record_link_depth>
Returns an array reference.
-Can only be called both as a class function since it is noe exported.
+Can only be called both as a class function since it is not exported.
=back