From 4bc8abba0059b4c7a490a43d1eebfb7a3b4e8647 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Wed, 30 Jul 2014 14:37:38 +0200 Subject: [PATCH] SL::DB::Unit::compatible_units: alle Einheiten gecachet laden --- SL/DB/Manager/Unit.pm | 5 +++++ SL/DB/Unit.pm | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/SL/DB/Manager/Unit.pm b/SL/DB/Manager/Unit.pm index f081af49e..673fcb060 100644 --- a/SL/DB/Manager/Unit.pm +++ b/SL/DB/Manager/Unit.pm @@ -41,4 +41,9 @@ sub convertible_to_filter { return ("${prefix}name" => [ map { $_->name } @{ $unit->convertible_units } ]); } +sub all_units { + my ($class) = @_; + $::request->cache('all_units')->{sorted} //= $class->get_all_sorted; +} + 1; diff --git a/SL/DB/Unit.pm b/SL/DB/Unit.pm index e8d260c67..900558fbd 100644 --- a/SL/DB/Unit.pm +++ b/SL/DB/Unit.pm @@ -27,8 +27,8 @@ sub unit_class { sub convertible_units { my $self = shift; - my $all_units = scalar(@_) && (ref($_[0]) eq 'ARRAY') ? $_[0] : \@_; - $all_units = SL::DB::Manager::Unit->get_all if !@{ $all_units }; + my $all_units = scalar(@_) && (ref($_[0]) eq 'ARRAY') ? $_[0] : [ @_ ]; + $all_units = SL::DB::Manager::Unit->all_units if ! @{ $all_units }; return [ sort { $a->sortkey <=> $b->sortkey } grep { $_->unit_class->name eq $self->unit_class->name } -- 2.20.1