Bugzilla – Attachment 153760 Details for
Bug 34335
Run Koha plugin method from CLI
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 34335: Add a script to run Koha plugin methods from the CLI
Bug-34335-Add-a-script-to-run-Koha-plugin-methods-.patch (text/plain), 2.97 KB, created by
Paul Derscheid
on 2023-07-21 08:54:23 UTC
(
hide
)
Description:
Bug 34335: Add a script to run Koha plugin methods from the CLI
Filename:
MIME Type:
Creator:
Paul Derscheid
Created:
2023-07-21 08:54:23 UTC
Size:
2.97 KB
patch
obsolete
>From 3d5b42ab5af8abd4c1a176f6c21d9f682fb7bb81 Mon Sep 17 00:00:00 2001 >From: David Cook <dcook@prosentient.com.au> >Date: Fri, 21 Jul 2023 01:25:21 +0000 >Subject: [PATCH] Bug 34335: Add a script to run Koha plugin methods from the > CLI > >This change adds a script which allows you to run a method from >a Koha plugin. > >Test plan: >0. Apply patch >1. Upload test plugin >2. Run the following: >perl misc/run_koha_plugin.pl --class Koha::Plugin::Prosentient::CustomMethodPlugin \ > --method awesome_method --params '{"msg": "this is awesome"}' >3. Note the following CLI messages: >This is a custom method that you're seeing on the CLI! >We got a message: this is awesome > >Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de> >--- > misc/run_koha_plugin.pl | 82 +++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 82 insertions(+) > create mode 100755 misc/run_koha_plugin.pl > >diff --git a/misc/run_koha_plugin.pl b/misc/run_koha_plugin.pl >new file mode 100755 >index 0000000000..155642b330 >--- /dev/null >+++ b/misc/run_koha_plugin.pl >@@ -0,0 +1,82 @@ >+#!/usr/bin/perl >+ >+# This file is part of Koha. >+# >+# Copyright 2023 Koha Development Team >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+ >+=head1 NAME >+ >+run_koha_plugin.pl - Script to execute a Koha plugin from the CLI >+ >+=head1 SYNOPSIS >+ >+./run_koha_plugin --class Koha::Plugin::Awesome --method awesome_method [--params '{"msg": "this is awesome"}'] >+ >+=head1 DESCRIPTION >+ >+This script will load the specified Koha plugin class and run the specified method >+ >+=head1 OPTIONS >+ >+=over >+ >+=item B<--class> >+ >+This is the class/package name of the Koha plugin in Perl module syntax >+ >+=item B<--method> >+ >+This is the name of the method to run. It must already be registered in Koha's >+database >+ >+=item B<--params> >+ >+You can optionally provide JSON-encoded parameters that will be passed to the plugin method >+ >+=back >+ >+=cut >+ >+use Modern::Perl; >+use Getopt::Long; >+use Pod::Usage; >+use JSON; >+ >+use Koha::Script; >+use Koha::Plugins::Handler; >+ >+my $class; >+my $method; >+my $params; >+my $json_params; >+ >+GetOptions( >+ "class=s" => \$class, >+ "method=s" => \$method, >+ "params=s" => \$json_params, >+) || pod2usage(1); >+ >+if ($json_params) { >+ my $json = JSON->new; >+ $params = $json->decode($json_params); >+} >+ >+if ( $class && $method ) { >+ my $result = Koha::Plugins::Handler->run( { class => $class, method => $method, params => $params, } ); >+} else { >+ pod2usage(1); >+} >-- >2.30.2
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 34335
:
153746
|
153747
|
153748
|
153749
| 153760