Lines 22-36
use Modern::Perl;
Link Here
|
22 |
use Template::Plugin; |
22 |
use Template::Plugin; |
23 |
use base qw( Template::Plugin ); |
23 |
use base qw( Template::Plugin ); |
24 |
|
24 |
|
|
|
25 |
use Koha::Cache::Memory::Lite; |
25 |
use Koha::ItemTypes; |
26 |
use Koha::ItemTypes; |
26 |
|
27 |
|
27 |
sub GetDescription { |
28 |
sub GetDescription { |
28 |
my ( $self, $itemtypecode, $want_parent ) = @_; |
29 |
my ( $self, $itemtypecode, $want_parent ) = @_; |
|
|
30 |
|
31 |
my $memory_cache = Koha::Cache::Memory::Lite->get_instance; |
32 |
my $cache_key = $want_parent ? "Itemtype_parent_description:".$itemtypecode : "Itemtype_description:" . $itemtypecode; |
33 |
my $cached = $memory_cache->get_from_cache($cache_key); |
34 |
return $cached if $cached; |
35 |
|
29 |
my $itemtype = Koha::ItemTypes->find( $itemtypecode ); |
36 |
my $itemtype = Koha::ItemTypes->find( $itemtypecode ); |
30 |
return q{} unless $itemtype; |
37 |
return q{} unless $itemtype; |
31 |
my $parent; |
38 |
my $parent; |
32 |
$parent = $itemtype->parent if $want_parent; |
39 |
$parent = $itemtype->parent if $want_parent; |
33 |
return $parent ? $parent->translated_description . "->" . $itemtype->translated_description : $itemtype->translated_description; |
40 |
my $description = $parent ? $parent->translated_description . "->" . $itemtype->translated_description : $itemtype->translated_description; |
|
|
41 |
$memory_cache->set_in_cache( $cache_key, $description ); |
42 |
return $description; |
34 |
} |
43 |
} |
35 |
|
44 |
|
36 |
sub Get { |
45 |
sub Get { |
37 |
- |
|
|