Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 3bc7e852

Von Sven Schöling vor etwa 1 Jahr hinzugefügt

  • ID 3bc7e8524b5ab13f42c0702b4dc67ec237c771cf
  • Vorgänger e8be6fb9
  • Nachfolger 320b8908

RecordLink: doku

Unterschiede anzeigen:

SL/DB/Helper/RecordLink.pm
113 113
      my ($self) = @_;
114 114
      SL::DB::Helper::RecordLink::link_records(
115 115
        $self,
116
        qw(SL::DB::Order),     # list of allowed record sources
117
        qw(SL::DB::OrderItem), # list of allowed record item sources
116
        qw(SL::DB::Order),            # list of allowed record sources
117
        qw(SL::DB::OrderItem),        # list of allowed record item sources
118
        close_source_quotations => 1, # if the link source is a quotation - close it
118 119
      )
119 120
    }
120 121

  
122
    # set conversion data in record
123
    sub prepare_linked_records {
124
      my @converted_from_ids      = @{ $::form->{converted_from_oe_ids} };
125
      my @converted_from_item_ids = @{ $::form->{converted_from_orderitem_ids} };
126

  
127
      set_record_link_conversion(
128
        $self->order,                                     # the record to modify
129
        'SL::DB::Order'     => \@converted_from_ids,      # singular or multiple source record ids
130
        'SL::DB::OrderItem' => \@converted_from_item_ids  # ids of items, each item will get one id
131
      );
132
    }
133

  
121 134
=head1 DESCRIPTION
122 135

  
123
...
136
This module implements reusable after save hooks for dealing with record links for records created from other records.
137

  
138
It reacts to non-rose attributes set in the underlying hashes of the given record:
139

  
140
=over 4
141

  
142
=item * C<converted_from_record_id>
143

  
144
=item * C<converted_from_record_type_ref>
145

  
146
=item * C<converted_from_record_item_id>
147

  
148
=item * C<converted_from_record_item_type_ref>
149

  
150
=back
151

  
152
If a typeref is given that is not explicitely whitelisted, an error will be thrown.
153

  
154
The older C<converted_from_oe_ids> etc forms can be converted with TODO
124 155

  
125 156
=head1 METHODS
126 157

  
127
...
158
=over 4
159

  
160
=item * C<set_record_link_conversions> $record, $record_type => \@ids, $item_type => \@item_ids
161

  
162
Register the given ids in the object to be linked after saving.
163

  
164
Item ids will be assigned one by one to sorted_items.
165

  
166
=item * C<link_records> $record, \@allowed_record_types, \@allowed_item_types
167

  
168
Intended as a post-save hook.
169
Evaluates the stored ids from L </set_record_link_conversions>
170
and links the creating objects to the given one.
171

  
172
=back
128 173

  
129 174
=head1 BUGS
130 175

  

Auch abrufbar als: Unified diff