Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
71.43% |
10 / 14 |
|
50.00% |
1 / 2 |
CRAP | |
0.00% |
0 / 1 |
AbstractEDSParams | |
71.43% |
10 / 14 |
|
50.00% |
1 / 2 |
9.49 | |
0.00% |
0 / 1 |
createBackendFilterParameters | |
66.67% |
8 / 12 |
|
0.00% |
0 / 1 |
8.81 | |||
getView | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | /** |
4 | * Common EDS & EPF API Params |
5 | * |
6 | * PHP version 8 |
7 | * |
8 | * Copyright (C) EBSCO Industries 2013 |
9 | * Copyright (C) The National Library of Finland 2022 |
10 | * Copyright (C) Villanova University 2023 |
11 | * |
12 | * This program is free software; you can redistribute it and/or modify |
13 | * it under the terms of the GNU General Public License version 2, |
14 | * as published by the Free Software Foundation. |
15 | * |
16 | * This program is distributed in the hope that it will be useful, |
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
19 | * GNU General Public License for more details. |
20 | * |
21 | * You should have received a copy of the GNU General Public License |
22 | * along with this program; if not, write to the Free Software |
23 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
24 | * |
25 | * @category VuFind |
26 | * @package EBSCO |
27 | * @author Michelle Milton <mmilton@epnet.com> |
28 | * @author Ere Maijala <ere.maijala@helsinki.fi> |
29 | * @author Maccabee Levine <msl321@lehigh.edu> |
30 | * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License |
31 | * @link https://vufind.org Main Page |
32 | */ |
33 | |
34 | namespace VuFind\Search\EDS; |
35 | |
36 | use VuFindSearch\ParamBag; |
37 | |
38 | /** |
39 | * Common EDS & EPF API Params |
40 | * |
41 | * @category VuFind |
42 | * @package EBSCO |
43 | * @author Michelle Milton <mmilton@epnet.com> |
44 | * @author Ere Maijala <ere.maijala@helsinki.fi> |
45 | * @author Maccabee Levine <msl321@lehigh.edu> |
46 | * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License |
47 | * @link https://vufind.org Main Page |
48 | */ |
49 | class AbstractEDSParams extends \VuFind\Search\Base\Params |
50 | { |
51 | /** |
52 | * Set up filters based on VuFind settings. |
53 | * |
54 | * @param ParamBag $params Parameter collection to update |
55 | * |
56 | * @return void |
57 | */ |
58 | public function createBackendFilterParameters(ParamBag $params) |
59 | { |
60 | // Which filters should be applied to our query? |
61 | $filterList = $this->getFilterList(); |
62 | $hiddenFilterList = $this->getHiddenFilters(); |
63 | if (!empty($filterList)) { |
64 | // Loop through all filters and add appropriate values to request: |
65 | foreach ($filterList as $filterArray) { |
66 | foreach ($filterArray as $filt) { |
67 | // Standard case: |
68 | $fq = "{$filt['field']}:{$filt['value']}"; |
69 | $params->add('filters', $fq); |
70 | } |
71 | } |
72 | } |
73 | if (!empty($hiddenFilterList)) { |
74 | foreach ($hiddenFilterList as $field => $hiddenFilters) { |
75 | foreach ($hiddenFilters as $value) { |
76 | // Standard case: |
77 | $hfq = "{$field}:{$value}"; |
78 | $params->add('filters', $hfq); |
79 | } |
80 | } |
81 | } |
82 | } |
83 | |
84 | /** |
85 | * Return the value for which search view we use |
86 | * |
87 | * @return string |
88 | */ |
89 | public function getView() |
90 | { |
91 | $viewArr = explode('|', $this->view ?? ''); |
92 | return $viewArr[0]; |
93 | } |
94 | } |