Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision ea20c6e3

Von Moritz Bunkus vor etwa 14 Jahren hinzugefügt

  • ID ea20c6e350ed5aea8dd57c48b798e8588186ea61
  • Vorgänger f3345acc
  • Nachfolger 0e43ef87

linked_records(): Mehrere Model-Namen bei 'from'-/'to'-Parametern

Unterschiede anzeigen:

SL/DB/Helper/LinkedRecords.pm
"${myself}_id" => $self->id );
if ($params{$wanted}) {
my $wanted_table = SL::DB::Helpers::Mappings::get_table_for_package($params{$wanted}) || croak("Invalid parameter `${wanted}'");
push @query, ("${wanted}_table" => $wanted_table);
my $wanted_classes = ref($params{$wanted}) eq 'ARRAY' ? $params{$wanted} : [ $params{$wanted} ];
my $wanted_tables = [ map { SL::DB::Helpers::Mappings::get_table_for_package($_) || croak("Invalid parameter `${wanted}'") } @{ $wanted_classes } ];
push @query, ("${wanted}_table" => $wanted_tables);
}
my $links = SL::DB::Manager::RecordLink->get_all(query => [ and => \@query ]);
......
C<$self> (for C<direction> = C<from>).
The optional parameter C<from> or C<to> (same as C<direction>)
contains the package name of a Rose model for table limitation. If you
only need invoices created from an order C<$order> then the call could
look like this:
contains the package names of Rose models for table limitation. It can
be a single model name as a single scalar or multiple model names in
an array reference in which case all links matching any of the model
names will be returned.
If you only need invoices created from an order C<$order> then the
call could look like this:
my $invoices = $order->linked_records(direction => 'to',
to => 'SL::DB::Invoice');

Auch abrufbar als: Unified diff