Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
n/a
0 / 0
n/a
0 / 0
CRAP
n/a
0 / 0
1<?php
2
3/**
4 * Search query adapter interface
5 *
6 * PHP version 8
7 *
8 * Copyright (C) Villanova University 2011.
9 * Copyright (C) The National Library of Finland 2024.
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2,
13 * as published by the Free Software Foundation.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
23 *
24 * @category VuFind
25 * @package  Search_Solr
26 * @author   Demian Katz <demian.katz@villanova.edu>
27 * @author   Ere Maijala <ere.maijala@helsinki.fi>
28 * @license  http://opensource.org/licenses/gpl-2.0.php GNU General Public License
29 * @link     https://vufind.org Main Page
30 */
31
32namespace VuFind\Search;
33
34use Laminas\Stdlib\Parameters;
35use VuFindSearch\Query\AbstractQuery;
36use VuFindSearch\Query\Query;
37use VuFindSearch\Query\QueryGroup;
38use VuFindSearch\Query\WorkKeysQuery;
39
40/**
41 * Search query adapter interface
42 *
43 * @category VuFind
44 * @package  Search_Solr
45 * @author   Demian Katz <demian.katz@villanova.edu>
46 * @author   Ere Maijala <ere.maijala@helsinki.fi>
47 * @license  http://opensource.org/licenses/gpl-2.0.php GNU General Public License
48 * @link     https://vufind.org Main Page
49 */
50interface QueryAdapterInterface
51{
52    /**
53     * Return a Query or QueryGroup based on minified search arguments.
54     *
55     * @param array $search Minified search arguments
56     *
57     * @return Query|QueryGroup|WorkKeysQuery
58     */
59    public function deminify(array $search);
60
61    /**
62     * Convert a Query or QueryGroup into a human-readable display query.
63     *
64     * @param AbstractQuery $query     Query to convert
65     * @param callable      $translate Callback to translate strings
66     * @param callable      $showName  Callback to translate field names
67     *
68     * @return string
69     */
70    public function display(AbstractQuery $query, $translate, $showName);
71
72    /**
73     * Convert user request parameters into a query (currently for advanced searches
74     * and work keys searches only).
75     *
76     * @param Parameters $request        User-submitted parameters
77     * @param string     $defaultHandler Default search handler
78     *
79     * @return Query|QueryGroup|WorkKeysQuery
80     */
81    public function fromRequest(Parameters $request, $defaultHandler);
82
83    /**
84     * Convert a Query or QueryGroup into minified search arguments.
85     *
86     * @param AbstractQuery $query    Query to minify
87     * @param bool          $topLevel Is this a top-level query? (Used for recursion)
88     *
89     * @return array
90     */
91    public function minify(AbstractQuery $query, $topLevel = true);
92}