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

(-)a/Koha/Plugins.pm (+24 lines)
Lines 139-144 sub get_enabled_plugins { Link Here
139
    return @$enabled_plugins;
139
    return @$enabled_plugins;
140
}
140
}
141
141
142
143
=head2 feature_enabled
144
145
Returns a boolean denoting whether a plugin based feature is enabled or not.
146
147
    $enabled = Koha::Plugins->feature_enabled('method_name');
148
149
=cut
150
151
sub feature_enabled {
152
    my ( $class, $method ) = @_;
153
154
    return 0 unless C4::Context->config('enable_plugins');
155
156
    my $key     = "ENABLED_PLUGIN_FEATURE_" . $method;
157
    my $feature = Koha::Cache::Memory::Lite->get_from_cache($key);
158
    unless ( defined($feature) ) {
159
        my @plugins = $class->get_enabled_plugins();
160
        my $enabled = any { $_->can($method) } @plugins;
161
        Koha::Cache::Memory::Lite->set_in_cache( $key, $enabled );
162
    }
163
    return $feature;
164
}
165
142
=head2 GetPlugins
166
=head2 GetPlugins
143
167
144
This will return a list of all available plugins, optionally limited by
168
This will return a list of all available plugins, optionally limited by
(-)a/Koha/Template/Plugin/KohaPlugins.pm (-1 / +17 lines)
Lines 282-285 sub get_plugins_opac_cover_images { Link Here
282
    return join( "\n", @data );
282
    return join( "\n", @data );
283
}
283
}
284
284
285
=head3 feature_enabled
286
287
  [% KohaPlugins.feature_enabled('method_name') %]
288
289
This method returns true if the passed plugin hook method name is found to be installed and enabled as part of a plugin.
290
291
=cut
292
293
sub feature_enabled {
294
    my ($self, $method) = @_;
295
296
    my $p = Koha::Plugins->new();
297
    return 0 unless $p;
298
299
    return $p->feature_enabled($method);
300
}
301
285
1;
302
1;
286
- 

Return to bug 31503