Revision 4bc8abba
Von Moritz Bunkus vor mehr als 10 Jahren hinzugefügt
SL/DB/Manager/Unit.pm | ||
---|---|---|
41 | 41 |
return ("${prefix}name" => [ map { $_->name } @{ $unit->convertible_units } ]); |
42 | 42 |
} |
43 | 43 |
|
44 |
sub all_units { |
|
45 |
my ($class) = @_; |
|
46 |
$::request->cache('all_units')->{sorted} //= $class->get_all_sorted; |
|
47 |
} |
|
48 |
|
|
44 | 49 |
1; |
SL/DB/Unit.pm | ||
---|---|---|
27 | 27 |
|
28 | 28 |
sub convertible_units { |
29 | 29 |
my $self = shift; |
30 |
my $all_units = scalar(@_) && (ref($_[0]) eq 'ARRAY') ? $_[0] : \@_;
|
|
31 |
$all_units = SL::DB::Manager::Unit->get_all if !@{ $all_units };
|
|
30 |
my $all_units = scalar(@_) && (ref($_[0]) eq 'ARRAY') ? $_[0] : [ @_ ];
|
|
31 |
$all_units = SL::DB::Manager::Unit->all_units if ! @{ $all_units };
|
|
32 | 32 |
return [ |
33 | 33 |
sort { $a->sortkey <=> $b->sortkey } |
34 | 34 |
grep { $_->unit_class->name eq $self->unit_class->name } |
Auch abrufbar als: Unified diff
SL::DB::Unit::compatible_units: alle Einheiten gecachet laden