Revision 3bd03753
Von Moritz Bunkus vor fast 14 Jahren hinzugefügt
SL/DB/Helper/LinkedRecords.pm | ||
---|---|---|
75 | 75 |
my @links; |
76 | 76 |
|
77 | 77 |
foreach my $direction (@directions) { |
78 |
my %params = ( $direction->[0] . "_table" => SL::DB::Helper::Mappings::get_table_for_package(ref($self)),
|
|
79 |
$direction->[0] . "_id" => $self->id,
|
|
80 |
$direction->[1] . "_table" => SL::DB::Helper::Mappings::get_table_for_package(ref($other)),
|
|
81 |
$direction->[1] . "_id" => $other->id,
|
|
82 |
);
|
|
83 |
|
|
84 |
my $link = SL::DB::Manager::RecordLink->find_by(and => [ %params ]);
|
|
85 |
push @links, $link ? $link : SL::DB::RecordLink->new(%params)->save unless $link;
|
|
78 |
my %data = ( $direction->[0] . "_table" => SL::DB::Helper::Mappings::get_table_for_package(ref($self)),
|
|
79 |
$direction->[0] . "_id" => $self->id, |
|
80 |
$direction->[1] . "_table" => SL::DB::Helper::Mappings::get_table_for_package(ref($other)), |
|
81 |
$direction->[1] . "_id" => $other->id, |
|
82 |
); |
|
83 |
|
|
84 |
my $link = SL::DB::Manager::RecordLink->find_by(and => [ %data ]);
|
|
85 |
push @links, $link ? $link : SL::DB::RecordLink->new(%data)->save unless $link;
|
|
86 | 86 |
} |
87 | 87 |
|
88 | 88 |
return wantarray ? @links : $links[0]; |
Auch abrufbar als: Unified diff
Keine lokalen Variablennamen doppelt vergeben