Bug 21073: Restore filtering by metadata
This patch restores filtering the plugins by metadata. That got lost on rebase at some point. Regression tests are added on a prior patch. To test: - Have the 'regression tests for GetPlugins' patch applied - Run: $ kshell k$ prove t/db_dependent/Plugins.t => FAIL: Tests fail! - Apply this patch - Run: k$ prove t/db_dependent/Plugins.t => SUCCESS: Tests pass! - Sign off :-D Signed-off-by: Agustin Moyano <agustinmoyano@theke.io> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
parent
e42b571269
commit
a080ffdf76
|
|
@ -20,6 +20,7 @@ package Koha::Plugins;
|
|||
use Modern::Perl;
|
||||
|
||||
use Class::Inspector;
|
||||
use List::MoreUtils qw(any);
|
||||
use Module::Load::Conditional qw(can_load);
|
||||
use Module::Load qw(load);
|
||||
use Module::Pluggable search_path => ['Koha::Plugin'], except => qr/::Edifact(|::Line|::Message|::Order|::Segment|::Transport)$/;
|
||||
|
|
@ -76,8 +77,14 @@ sub GetPlugins {
|
|||
my $plugin_classes = $dbh->selectcol_arrayref('SELECT DISTINCT(plugin_class) FROM plugin_methods');
|
||||
my @plugins;
|
||||
|
||||
# Loop through all plugins that implement at least a method
|
||||
foreach my $plugin_class (@$plugin_classes) {
|
||||
next if $method && !Koha::Plugins::Methods->search({ plugin_class => $plugin_class, plugin_method => $method })->count;
|
||||
# filter the plugin out by method
|
||||
next
|
||||
if $method
|
||||
&& !Koha::Plugins::Methods->search(
|
||||
{ plugin_class => $plugin_class, plugin_method => $method } )->count;
|
||||
|
||||
load $plugin_class;
|
||||
my $plugin = $plugin_class->new({ enable_plugins => $self->{'enable_plugins'} });
|
||||
|
||||
|
|
@ -91,8 +98,17 @@ sub GetPlugins {
|
|||
|
||||
next unless $plugin_enabled;
|
||||
|
||||
# filter the plugin out by metadata
|
||||
my $plugin_metadata = $plugin->get_metadata;
|
||||
next
|
||||
if $plugin_metadata
|
||||
and %$req_metadata
|
||||
and any { !$plugin_metadata->{$_} || $plugin_metadata->{$_} ne $req_metadata->{$_} } keys %$req_metadata;
|
||||
|
||||
push @plugins, $plugin;
|
||||
|
||||
}
|
||||
|
||||
return @plugins;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue