Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 24 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
Results | |
0.00% |
0 / 24 |
|
0.00% |
0 / 2 |
42 | |
0.00% |
0 / 1 |
performSearch | |
0.00% |
0 / 21 |
|
0.00% |
0 / 1 |
20 | |||
getFacetList | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 |
1 | <?php |
2 | |
3 | /** |
4 | * EDS API Results |
5 | * |
6 | * PHP version 8 |
7 | * |
8 | * Copyright (C) Villanova University 2022. |
9 | * Copyright (C) EBSCO Industries 2013 |
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 EBSCO |
26 | * @author Michelle Milton <mmilton@epnet.com> |
27 | * @author Sudharma Kellampalli <skellamp@villanova.edu> |
28 | * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License |
29 | * @link https://vufind.org Main Page |
30 | */ |
31 | |
32 | namespace VuFind\Search\EDS; |
33 | |
34 | use VuFindSearch\Command\SearchCommand; |
35 | |
36 | /** |
37 | * EDS API Results |
38 | * |
39 | * @category VuFind |
40 | * @package EBSCO |
41 | * @author Michelle Milton <mmilton@epnet.com> |
42 | * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License |
43 | * @link https://vufind.org Main Page |
44 | */ |
45 | class Results extends \VuFind\Search\Base\Results |
46 | { |
47 | /** |
48 | * Search backend identifier. |
49 | * |
50 | * @var string |
51 | */ |
52 | protected $backendId = 'EDS'; |
53 | |
54 | /** |
55 | * Facet list |
56 | * |
57 | * @var array |
58 | */ |
59 | protected $responseFacets; |
60 | |
61 | /** |
62 | * Support method for performAndProcessSearch -- perform a search based on the |
63 | * parameters passed to the object. |
64 | * |
65 | * @return void |
66 | */ |
67 | protected function performSearch() |
68 | { |
69 | $query = $this->getParams()->getQuery(); |
70 | $limit = $this->getParams()->getLimit(); |
71 | $offset = $this->getStartRecord() - 1; |
72 | $params = $this->getParams()->getBackendParameters(); |
73 | $command = new SearchCommand( |
74 | $this->backendId, |
75 | $query, |
76 | $offset, |
77 | $limit, |
78 | $params |
79 | ); |
80 | $collection = $this->getSearchService()->invoke($command) |
81 | ->getResult(); |
82 | if (null != $collection) { |
83 | $this->responseFacets = $collection->getFacets(); |
84 | $this->resultTotal = $collection->getTotal(); |
85 | |
86 | // Add fake date facets if flagged earlier; this is necessary in order |
87 | // to display the date range facet control in the interface. |
88 | $dateFacets = $this->getParams()->getDateFacetSettings(); |
89 | if (!empty($dateFacets)) { |
90 | foreach ($dateFacets as $dateFacet) { |
91 | $this->responseFacets[$dateFacet] = ['']; |
92 | } |
93 | } |
94 | |
95 | // Construct record drivers for all the items in the response: |
96 | $this->results = $collection->getRecords(); |
97 | } |
98 | } |
99 | |
100 | /** |
101 | * Returns the stored list of facets for the last search |
102 | * |
103 | * @param array $filter Array of field => on-screen description listing |
104 | * all of the desired facet fields; set to null to get all configured values. |
105 | * |
106 | * @return array Facets data arrays |
107 | */ |
108 | public function getFacetList($filter = null) |
109 | { |
110 | if (null === $this->responseFacets) { |
111 | $this->performAndProcessSearch(); |
112 | } |
113 | return $this->buildFacetList($this->responseFacets, $filter); |
114 | } |
115 | } |