View | Details | Raw Unified | Return to bug 29454
Collapse All | Expand All

(-)a/Koha/Template/Plugin/ItemTypes.pm (-3 / +19 lines)
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
    return q{} unless defined $itemtypecode;
31
32
    my $memory_cache = Koha::Cache::Memory::Lite->get_instance;
33
    my $cache_key    = $want_parent ? "Itemtype_parent_description:".$itemtypecode : "Itemtype_description:" . $itemtypecode;
34
35
    my $cached       = $memory_cache->get_from_cache($cache_key);
36
    return $cached if $cached;
37
29
    my $itemtype = Koha::ItemTypes->find( $itemtypecode );
38
    my $itemtype = Koha::ItemTypes->find( $itemtypecode );
30
    return q{} unless $itemtype;
39
    unless ($itemtype) {
40
        $memory_cache->set_in_cache( $cache_key, q{} );
41
        return q{};
42
    }
43
31
    my $parent;
44
    my $parent;
32
    $parent = $itemtype->parent if $want_parent;
45
    $parent = $itemtype->parent if $want_parent;
33
    return $parent ? $parent->translated_description . "->" . $itemtype->translated_description : $itemtype->translated_description;
46
47
    my $description = $parent ? $parent->translated_description . "->" . $itemtype->translated_description : $itemtype->translated_description;
48
    $memory_cache->set_in_cache( $cache_key, $description );
49
50
    return $description;
34
}
51
}
35
52
36
sub Get {
53
sub Get {
37
- 

Return to bug 29454