Bugzilla – Attachment 67109 Details for
Bug 19306
Adding hooks to the plugin system
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Adding hooks to the plugin system
Adding-hooks-to-the-plugin-system.patch (text/plain), 3.23 KB, created by
Stefan Berndtsson
on 2017-09-13 09:45:42 UTC
(
hide
)
Description:
Adding hooks to the plugin system
Filename:
MIME Type:
Creator:
Stefan Berndtsson
Created:
2017-09-13 09:45:42 UTC
Size:
3.23 KB
patch
obsolete
>From a9451343fbe6e72cb7491384f5d758d235768f3d Mon Sep 17 00:00:00 2001 >From: Stefan Berndtsson <stefan.berndtsson@gmail.com> >Date: Tue, 12 Sep 2017 12:47:00 +0200 >Subject: [PATCH] Adding hooks to the plugin system > >https://bugs.koha-community.org/show_bug.cgi?id=19306 >--- > Koha/Plugins/Handler.pm | 30 +++++++++++++++++++++++++ > Koha/SearchEngine/Elasticsearch/QueryBuilder.pm | 30 +++++++++++++++++++++++++ > 2 files changed, 60 insertions(+) > >diff --git a/Koha/Plugins/Handler.pm b/Koha/Plugins/Handler.pm >index 5b6e3e3..a821ecb 100644 >--- a/Koha/Plugins/Handler.pm >+++ b/Koha/Plugins/Handler.pm >@@ -24,6 +24,7 @@ use File::Path qw(remove_tree); > use Module::Load::Conditional qw(can_load); > > use C4::Context; >+use Koha::Plugins; > > BEGIN { > my $pluginsdir = C4::Context->config("pluginsdir"); >@@ -73,6 +74,35 @@ sub run { > } > } > >+=item run_matching >+ >+Run all plugins in sequence matching plugin_method >+ >+=cut >+ >+sub run_matching { >+ my ( $class, $args ) = @_; >+ my $params = $args->{'params'}; >+ return $params unless ( C4::Context->config("enable_plugins") || $args->{'enable_plugins'} ); >+ >+ my $plugin_method = $args->{'method'}; >+ my @plugins = Koha::Plugins->new()->GetPlugins({ >+ method => $plugin_method >+ }); >+ >+ foreach my $plugin (@plugins) { >+ $params = Koha::Plugins::Handler->run( >+ { >+ class => $plugin->{'class'}, >+ method => $plugin_method, >+ params => $params >+ } >+ ); >+ } >+ >+ return $params; >+} >+ > =item delete > > Deletes a plugin >diff --git a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm >index fbd4370..ca48232 100644 >--- a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm >+++ b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm >@@ -45,6 +45,7 @@ use JSON; > use List::MoreUtils qw/ each_array /; > use Modern::Perl; > use URI::Escape; >+use Koha::Plugins::Handler; > > use C4::Context; > use Data::Dumper; # TODO remove >@@ -200,6 +201,35 @@ sub build_query_compat { > $lang, $params ) > = @_; > >+ >+ my $plugin_result = Koha::Plugins::Handler->run_matching( >+ { >+ method => 'build_query_before', >+ params => { >+ operators => $operators, >+ operands => $operands, >+ indexes => $indexes, >+ orig_limits => $orig_limits, >+ sort_by => $sort_by, >+ scan => $scan, >+ lang => $lang, >+ params => $params >+ }, >+ engine => 'elasticsearch' >+ } >+ ); >+ >+ ($operators, $operands, $indexes, $orig_limits, $sort_by, $scan, $lang, $params) = ( >+ $plugin_result->{'operators'}, >+ $plugin_result->{'operands'}, >+ $plugin_result->{'indexes'}, >+ $plugin_result->{'orig_limits'}, >+ $plugin_result->{'sort_by'}, >+ $plugin_result->{'scan'}, >+ $plugin_result->{'lang'}, >+ $plugin_result->{'params'}, >+ ); >+ > #die Dumper ( $self, $operators, $operands, $indexes, $orig_limits, $sort_by, $scan, $lang ); > my @sort_params = $self->_convert_sort_fields(@$sort_by); > my @index_params = $self->_convert_index_fields(@$indexes); >-- >2.7.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 19306
:
67108
| 67109