|
Lines 80-86
sub call {
Link Here
|
| 80 |
return unless C4::Context->config('enable_plugins'); |
80 |
return unless C4::Context->config('enable_plugins'); |
| 81 |
|
81 |
|
| 82 |
my @responses; |
82 |
my @responses; |
| 83 |
my @plugins = $class->get_enabled_plugins(); |
83 |
my @plugins = $class->get_enabled_plugins($method); |
| 84 |
@plugins = grep { $_->can($method) } @plugins; |
84 |
@plugins = grep { $_->can($method) } @plugins; |
| 85 |
|
85 |
|
| 86 |
# TODO: Remove warn when after_hold_create is removed from the codebase |
86 |
# TODO: Remove warn when after_hold_create is removed from the codebase |
|
Lines 104-115
sub call {
Link Here
|
| 104 |
|
104 |
|
| 105 |
Returns a list of enabled plugins. |
105 |
Returns a list of enabled plugins. |
| 106 |
|
106 |
|
| 107 |
@plugins = Koha::Plugins->get_enabled_plugins(); |
107 |
@plugins = Koha::Plugins->get_enabled_plugins([$method]); |
| 108 |
|
108 |
|
| 109 |
=cut |
109 |
=cut |
| 110 |
|
110 |
|
| 111 |
sub get_enabled_plugins { |
111 |
sub get_enabled_plugins { |
| 112 |
my ($class) = @_; |
112 |
my ( $class, $method ) = @_; |
| 113 |
|
113 |
|
| 114 |
return unless C4::Context->config('enable_plugins'); |
114 |
return unless C4::Context->config('enable_plugins'); |
| 115 |
|
115 |
|
|
Lines 119-124
sub get_enabled_plugins {
Link Here
|
| 119 |
my $rs = Koha::Database->schema->resultset('PluginData'); |
119 |
my $rs = Koha::Database->schema->resultset('PluginData'); |
| 120 |
$rs = $rs->search({ plugin_key => '__ENABLED__', plugin_value => 1 }); |
120 |
$rs = $rs->search({ plugin_key => '__ENABLED__', plugin_value => 1 }); |
| 121 |
my @plugin_classes = $rs->get_column('plugin_class')->all(); |
121 |
my @plugin_classes = $rs->get_column('plugin_class')->all(); |
|
|
122 |
|
| 123 |
# Filter any enabled plugins that don't have the given method if one was passed in |
| 124 |
if ($method) { |
| 125 |
my @plugin_classes_with_method = Koha::Plugins::Methods->search( |
| 126 |
{ method => $method }, |
| 127 |
{ |
| 128 |
columns => 'plugin_class', |
| 129 |
distinct => 1 |
| 130 |
} |
| 131 |
)->as_list; |
| 132 |
|
| 133 |
my %seen = map { $_ => 1 } @plugin_classes; |
| 134 |
my @plugin_classes = grep { $seen{$_} } @plugin_classes_with_method; |
| 135 |
} |
| 136 |
|
| 122 |
foreach my $plugin_class (@plugin_classes) { |
137 |
foreach my $plugin_class (@plugin_classes) { |
| 123 |
unless (can_load(modules => { $plugin_class => undef }, nocache => 1)) { |
138 |
unless (can_load(modules => { $plugin_class => undef }, nocache => 1)) { |
| 124 |
warn "Failed to load $plugin_class: $Module::Load::Conditional::ERROR"; |
139 |
warn "Failed to load $plugin_class: $Module::Load::Conditional::ERROR"; |
| 125 |
- |
|
|