Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 71b7d7ca

Von Tamino Steinert vor 9 Monaten hinzugefügt

  • ID 71b7d7ca906ea8a82c98ff1750d1b40e0aa1e886
  • Vorgänger 65987c7f
  • Nachfolger a02fba71

S:M:Record: Funktionsreihenfolge geändert

Unterschiede anzeigen:

SL/Model/Record.pm
32 32
use SL::Util qw(trim);
33 33
use SL::Locale::String qw(t8);
34 34

  
35
sub get_record {
36
  my ($class, $type, $id) = @_;
37
  my $record_class = get_class_from_type($type);
38
  my $type_data_proxy = get_type_data_proxy_from_type($type);
39
  my $items_key = $type_data_proxy->properties('items_key');
40
  return $record_class->new(id => $id)->load(
41
    with => [ $items_key, "$items_key.part" ]
42
  );
43
}
44

  
45
sub create_new_record {
46
  my ($class, $type) = @_;
47
  my $record_class = get_class_from_type($type);
48
  # add_items adds items to an record with no items for saving, but they cannot
49
  # be retrieved via items until the record is saved. Adding empty items to new
50
  # record here solves this problem.
51
  return $record_class->new(
52
    items        => [],
53
    record_type  => $type,
54
    currency_id  => $::instance_conf->get_currency_id(),
55
  );
56
}
57

  
58
sub create_new_record_item {
59
  my ($class, $record_type) = @_;
60
  my $items_class = get_items_class_from_type($record_type);
61
  # add_custom_variables adds cvars to an item with no cvars for saving, but
62
  # they cannot be retrieved via custom_variables until the record/record_item is
63
  # saved. Adding empty custom_variables to new item here solves this problem.
64
  return $items_class->new(custom_variables => []);
65
}
35 66

  
36 67
sub update_after_new {
37 68
  my ($class, $new_record, %flags) = @_;
......
71 102
  return $record;
72 103
}
73 104

  
74
sub get_record {
75
  my ($class, $type, $id) = @_;
76
  my $record_class = get_class_from_type($type);
77
  my $type_data_proxy = get_type_data_proxy_from_type($type);
78
  my $items_key = $type_data_proxy->properties('items_key');
79
  return $record_class->new(id => $id)->load(
80
    with => [ $items_key, "$items_key.part" ]
81
  );
82
}
83

  
84
sub create_new_record {
85
  my ($class, $type) = @_;
86
  my $record_class = get_class_from_type($type);
87
  # add_items adds items to an record with no items for saving, but they cannot
88
  # be retrieved via items until the record is saved. Adding empty items to new
89
  # record here solves this problem.
90
  return $record_class->new(
91
    items        => [],
92
    record_type  => $type,
93
    currency_id  => $::instance_conf->get_currency_id(),
94
  );
95
}
96

  
97
sub create_new_record_item {
98
  my ($class, $record_type) = @_;
99
  my $items_class = get_items_class_from_type($record_type);
100
  # add_custom_variables adds cvars to an item with no cvars for saving, but
101
  # they cannot be retrieved via custom_variables until the record/record_item is
102
  # saved. Adding empty custom_variables to new item here solves this problem.
103
  return $items_class->new(custom_variables => []);
104
}
105

  
106 105
sub new_from_workflow {
107 106
  my ($class, $source_object, $target_type, %flags) = @_;
108 107

  

Auch abrufbar als: Unified diff