Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 18
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
Results
0.00% covered (danger)
0.00%
0 / 18
0.00% covered (danger)
0.00%
0 / 2
12
0.00% covered (danger)
0.00%
0 / 1
 performSearch
0.00% covered (danger)
0.00%
0 / 17
0.00% covered (danger)
0.00%
0 / 1
6
 isSavedSearch
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3/**
4 * AuthorFacets aspect of the Search Multi-class (Results)
5 *
6 * PHP version 8
7 *
8 * Copyright (C) Villanova University 2010, 2022.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2,
12 * as published by the Free Software Foundation.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
22 *
23 * @category VuFind
24 * @package  Search_SolrAuthorFacets
25 * @author   Demian Katz <demian.katz@villanova.edu>
26 * @license  http://opensource.org/licenses/gpl-2.0.php GNU General Public License
27 * @link     https://vufind.org Main Site
28 */
29
30namespace VuFind\Search\SolrAuthorFacets;
31
32use VuFindSearch\Command\SearchCommand;
33
34use function array_slice;
35use function count;
36
37/**
38 * AuthorFacets Search Results
39 *
40 * @category VuFind
41 * @package  Search_SolrAuthorFacets
42 * @author   Demian Katz <demian.katz@villanova.edu>
43 * @license  http://opensource.org/licenses/gpl-2.0.php GNU General Public License
44 * @link     https://vufind.org Main Site
45 */
46class Results extends \VuFind\Search\Solr\Results
47{
48    /**
49     * Support method for performAndProcessSearch -- perform a search based on the
50     * parameters passed to the object.
51     *
52     * @return void
53     */
54    protected function performSearch()
55    {
56        $query = $this->getParams()->getQuery();
57        $params = $this->getParams()->getBackendParameters();
58        // Perform the search:
59        $command = new SearchCommand($this->backendId, $query, 0, 0, $params);
60        $collection = $this->getSearchService()
61            ->invoke($command)->getResult();
62        $this->responseFacets = $collection->getFacets();
63
64        // Get the facets from which we will build our results:
65        $facets = $this->getFacetList(['author_facet' => null]);
66        if (isset($facets['author_facet'])) {
67            $params = $this->getParams();
68            $this->resultTotal
69                = (($params->getPage() - 1) * $params->getLimit())
70                + count($facets['author_facet']['list']);
71            $this->results = array_slice(
72                $facets['author_facet']['list'],
73                0,
74                $params->getLimit()
75            );
76        }
77    }
78
79    /**
80     * Is the current search saved in the database?
81     *
82     * @return bool
83     */
84    public function isSavedSearch()
85    {
86        // Author searches are never saved:
87        return false;
88    }
89}