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

(-)a/Koha/Plugins.pm (-20 / +22 lines)
Lines 70-102 If you pass multiple keys in the metadata hash, all keys must match. Link Here
70
70
71
sub GetPlugins {
71
sub GetPlugins {
72
    my ( $self, $params ) = @_;
72
    my ( $self, $params ) = @_;
73
    my $method = $params->{method};
73
74
    my $method       = $params->{method};
74
    my $req_metadata = $params->{metadata} // {};
75
    my $req_metadata = $params->{metadata} // {};
75
76
76
    my $dbh = C4::Context->dbh;
77
    my $filter = ( $method ) ? { plugin_method => $method } : undef;
77
    my $plugin_classes = $dbh->selectcol_arrayref('SELECT DISTINCT(plugin_class) FROM plugin_methods');
78
79
    my $plugin_classes = Koha::Plugins::Methods->search(
80
        $filter,
81
        {   columns  => 'plugin_class',
82
            distinct => 1
83
        }
84
    )->_resultset->get_column('plugin_class');
85
78
    my @plugins;
86
    my @plugins;
79
87
80
    # Loop through all plugins that implement at least a method
88
    # Loop through all plugins that implement at least a method
81
    foreach my $plugin_class (@$plugin_classes) {
89
    while ( my $plugin_class = $plugin_classes->next ) {
82
        # filter the plugin out by method
83
        next
84
            if $method
85
            && !Koha::Plugins::Methods->search(
86
            { plugin_class => $plugin_class, plugin_method => $method } )->count;
87
90
88
        load $plugin_class;
91
        load $plugin_class;
89
        my $plugin = $plugin_class->new({ enable_plugins => $self->{'enable_plugins'} });
92
        my $plugin = $plugin_class->new({
93
            enable_plugins => $self->{'enable_plugins'}
94
                # loads even if plugins are disabled
95
                # FIXME: is this for testing without bothering to mock config?
96
        });
90
97
91
        my $plugin_enabled = $plugin->retrieve_data('__ENABLED__');
98
        next unless $plugin->is_enabled or
92
        $plugin->{enabled} = $plugin_enabled;
99
                    defined($params->{all}) && $params->{all};
93
94
        # Want all plugins. Not only enabled ones.
95
        if ( defined($params->{all}) && $params->{all} ) {
96
            $plugin_enabled = 1;
97
        }
98
99
        next unless $plugin_enabled;
100
100
101
        # filter the plugin out by metadata
101
        # filter the plugin out by metadata
102
        my $plugin_metadata = $plugin->get_metadata;
102
        my $plugin_metadata = $plugin->get_metadata;
Lines 120-125 This method iterates through all plugins physically present on a system. Link Here
120
For each plugin module found, it will test that the plugin can be loaded,
120
For each plugin module found, it will test that the plugin can be loaded,
121
and if it can, will store its available methods in the plugin_methods table.
121
and if it can, will store its available methods in the plugin_methods table.
122
122
123
NOTE: We re-load all plugins here as a protective measure in case someone
124
has removed a plugin directly from the system without using the UI
125
123
=cut
126
=cut
124
127
125
sub InstallPlugins {
128
sub InstallPlugins {
126
- 

Return to bug 21073