Bug 9978: Replace license header with the correct license (GPLv3+)
[koha-equinox.git] / Koha / SuggestionEngine / Base.pm
1 package Koha::SuggestionEngine::Base;
2
3 # Copyright 2012 C & P Bibliography Services
4 #
5 # This file is part of Koha.
6 #
7 # Koha is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
11 #
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20 =head1 NAME
21
22 Koha::SuggestionEngine::Base - Base class for SuggestionEngine plugins
23
24 =head1 SYNOPSIS
25
26   use base qw(Koha::SuggestionEngine::Base);
27
28 =head1 DESCRIPTION
29
30 Base class for suggestion engine plugins. SuggestionEngines must
31 provide the following methods:
32
33 B<get_suggestions (\%param)> - get suggestions for the search described
34 in $param->{'search'}, and return them in a hashref with the suggestions
35 as keys and relevance as values.
36
37 B<NAME> - return a string with the name of the plugin.
38
39 B<VERSION> - return a string with the version of the plugin.
40
41 These methods may be overriden:
42
43 B<initialize (%params)> - initialize the plugin
44
45 B<destroy ()> - destroy the plugin
46
47 These methods should not be overridden unless you are very sure of what
48 you are doing:
49
50 B<new ()> - create a new plugin object
51
52 =head1 FUNCTIONS
53
54 =cut
55
56 use strict;
57 use warnings;
58
59 use base qw(Class::Accessor);
60
61 __PACKAGE__->mk_ro_accessors(qw( name version ));
62 __PACKAGE__->mk_accessors(qw( params ));
63
64 =head2 new
65
66     my $plugin = Koha::SuggestionEngine::Base->new;
67
68 Create a new filter;
69
70 =cut
71
72 sub new {
73     my $class = shift;
74
75     my $self = $class->SUPER::new( {} );    #name => $class->NAME,
76                                             #version => $class->VERSION });
77
78     bless $self, $class;
79     return $self;
80 }
81
82 =head2 initialize
83
84     $plugin->initalize(%params);
85
86 Initialize a filter using the specified parameters.
87
88 =cut
89
90 sub initialize {
91     my $self   = shift;
92     my $params = shift;
93
94     #$self->params = $params;
95
96     return $self;
97 }
98
99 =head2 destroy
100
101     $plugin->destroy();
102
103 Destroy the filter.
104
105 =cut
106
107 sub destroy {
108     my $self = shift;
109     return;
110 }
111
112 =head2 get_suggestions
113
114     my $suggestions = $plugin->get_suggestions(\%param);
115
116 Return suggestions for the specified search.
117
118 =cut
119
120 sub get_suggestions {
121     my $self  = shift;
122     my $param = shift;
123     return;
124 }
125
126 1;