|
Lines 118-141
sub GetPlugins {
Link Here
|
| 118 |
# Loop through all plugins that implement at least a method |
118 |
# Loop through all plugins that implement at least a method |
| 119 |
while ( my $plugin_class = $plugin_classes->next ) { |
119 |
while ( my $plugin_class = $plugin_classes->next ) { |
| 120 |
|
120 |
|
| 121 |
load $plugin_class; |
121 |
if ( can_load( modules => { $plugin_class => undef }, nocache => 1 ) ) { |
| 122 |
my $plugin = $plugin_class->new({ |
122 |
my $plugin = $plugin_class->new({ |
| 123 |
enable_plugins => $self->{'enable_plugins'} |
123 |
enable_plugins => $self->{'enable_plugins'} |
| 124 |
# loads even if plugins are disabled |
124 |
# loads even if plugins are disabled |
| 125 |
# FIXME: is this for testing without bothering to mock config? |
125 |
# FIXME: is this for testing without bothering to mock config? |
| 126 |
}); |
126 |
}); |
| 127 |
|
127 |
|
| 128 |
next unless $plugin->is_enabled or |
128 |
next unless $plugin->is_enabled or |
| 129 |
defined($params->{all}) && $params->{all}; |
129 |
defined($params->{all}) && $params->{all}; |
| 130 |
|
130 |
|
| 131 |
# filter the plugin out by metadata |
131 |
# filter the plugin out by metadata |
| 132 |
my $plugin_metadata = $plugin->get_metadata; |
132 |
my $plugin_metadata = $plugin->get_metadata; |
| 133 |
next |
133 |
next |
| 134 |
if $plugin_metadata |
134 |
if $plugin_metadata |
| 135 |
and %$req_metadata |
135 |
and %$req_metadata |
| 136 |
and any { !$plugin_metadata->{$_} || $plugin_metadata->{$_} ne $req_metadata->{$_} } keys %$req_metadata; |
136 |
and any { !$plugin_metadata->{$_} || $plugin_metadata->{$_} ne $req_metadata->{$_} } keys %$req_metadata; |
| 137 |
|
137 |
|
| 138 |
push @plugins, $plugin; |
138 |
push @plugins, $plugin; |
|
|
139 |
} elsif ( defined($params->{errors}) && $params->{errors} ){ |
| 140 |
push @plugins, { error => 'cannot_load', name => $plugin_class }; |
| 141 |
} |
| 139 |
|
142 |
|
| 140 |
} |
143 |
} |
| 141 |
|
144 |
|
|
Lines 161-173
sub InstallPlugins {
Link Here
|
| 161 |
my @plugin_classes = $self->plugins(); |
164 |
my @plugin_classes = $self->plugins(); |
| 162 |
my @plugins; |
165 |
my @plugins; |
| 163 |
|
166 |
|
|
|
167 |
# If we can reload the plugin we will add the methods back, if not they should be removed |
| 168 |
Koha::Plugins::Methods->search()->delete(); |
| 164 |
foreach my $plugin_class (@plugin_classes) { |
169 |
foreach my $plugin_class (@plugin_classes) { |
| 165 |
if ( can_load( modules => { $plugin_class => undef }, nocache => 1 ) ) { |
170 |
if ( can_load( modules => { $plugin_class => undef }, nocache => 1 ) ) { |
| 166 |
next unless $plugin_class->isa('Koha::Plugins::Base'); |
171 |
next unless $plugin_class->isa('Koha::Plugins::Base'); |
| 167 |
|
172 |
|
| 168 |
my $plugin = $plugin_class->new({ enable_plugins => $self->{'enable_plugins'} }); |
173 |
my $plugin = $plugin_class->new({ enable_plugins => $self->{'enable_plugins'} }); |
| 169 |
|
174 |
|
| 170 |
Koha::Plugins::Methods->search({ plugin_class => $plugin_class })->delete(); |
|
|
| 171 |
|
175 |
|
| 172 |
foreach my $method ( @{ Class::Inspector->methods( $plugin_class, 'public' ) } ) { |
176 |
foreach my $method ( @{ Class::Inspector->methods( $plugin_class, 'public' ) } ) { |
| 173 |
Koha::Plugins::Method->new( |
177 |
Koha::Plugins::Method->new( |