Koha Plugin Hooks

From Koha Wiki

Jump to: navigation, search
Koha > Technical

We call plugin hooks to the places in Koha where the installed plugins are queried to check which ones implement specific methods. For example, there are hooks in the OPAC to allow plugins to inject *JavaScript* code in the templates in runtime.

This is accomplished by requiring plugins to implement specific methods in order to provide the functionality. For example, in order to inject API routes using plugins, Koha does this:

    if (   C4::Context->preference('UseKohaPlugins')
        && C4::Context->config("enable_plugins") )
    {
        # plugin needs to define a namespace
        @plugins = Koha::Plugins->new()->GetPlugins(
            {
                method => 'api_namespace',
            }
        );
    }

    foreach my $plugin ( @plugins ) {
        $spec = inject_routes( $spec, $plugin, $validator );
    }

So it queries for plugins that implement the *api_namespace* method, and then (somehow) uses that method from the resulting plugins list.

Implemented hooks

Method Use Description First version Bug
after_biblio_action C4::Biblio This method targets the use case in which you want to do some actions when CRUD operations on bibliographic records take place. For example, notifying an external system of the change. The actions should be done asynchronously to avoid performance hits. This method could add tasks to a task queue. 19.11.00 22709
after_item_action C4::Items This method targets the use case in which you want to do some actions when CRUD operations on items take place. For example, notifying an external system of the change. The actions should be done asynchronously to avoid performance hits. This method could add tasks to a task queue. 19.11.00 22709
intranet_catalog_biblio_tab catalogue/detail.pl This method should return an array of hashrefs that contain the keys title and content. This will have the effect of adding new tabs to the intranet biblio detail view. content key can contain HTML. - 23050


Developer handbook

Personal tools