Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
RecordVersionsSearchTrait | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
30 | |
0.00% |
0 / 1 |
versionsAction | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
30 |
1 | <?php |
2 | |
3 | /** |
4 | * VuFind Action Feature Trait - Record Versions Search |
5 | * Depends on method getSearchResultsView. |
6 | * |
7 | * PHP version 8 |
8 | * |
9 | * Copyright (C) The National Library of Finland 2020. |
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 Controller_Plugins |
26 | * @author Ere Maijala <ere.maijala@helsinki.fi> |
27 | * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License |
28 | * @link https://vufind.org Main Page |
29 | */ |
30 | |
31 | namespace VuFind\Controller\Feature; |
32 | |
33 | use VuFindSearch\Query\WorkKeysQuery; |
34 | |
35 | use function is_callable; |
36 | |
37 | /** |
38 | * VuFind Action Feature Trait - Record Versions Search |
39 | * |
40 | * @category VuFind |
41 | * @package Controller_Plugins |
42 | * @author Ere Maijala <ere.maijala@helsinki.fi> |
43 | * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License |
44 | * @link https://vufind.org Main Page |
45 | */ |
46 | trait RecordVersionsSearchTrait |
47 | { |
48 | /** |
49 | * Show results of versions search. |
50 | * |
51 | * @return mixed |
52 | */ |
53 | public function versionsAction() |
54 | { |
55 | // Don't save to history -- history page doesn't handle correctly: |
56 | $this->saveToHistory = false; |
57 | |
58 | $id = null; |
59 | $callback = function ($runner, $params, $searchId) use (&$id) { |
60 | $query = $params->getQuery(); |
61 | if ($query instanceof WorkKeysQuery) { |
62 | $id = $query->getId(); |
63 | } |
64 | $defaultCallback = is_callable([$this, 'getSearchSetupCallback']) |
65 | ? $this->getSearchSetupCallback() : null; |
66 | if (is_callable($defaultCallback)) { |
67 | $defaultCallback($runner, $params, $searchId); |
68 | } |
69 | $options = $params->getOptions(); |
70 | $options->disableHighlighting(); |
71 | $options->spellcheckEnabled(false); |
72 | }; |
73 | |
74 | $view = $this->getSearchResultsView($callback); |
75 | if (null !== $id) { |
76 | $loader = $this->serviceLocator->get(\VuFind\Record\Loader::class); |
77 | $view->driver = $loader->load($id, $this->searchClassId); |
78 | } |
79 | return $view; |
80 | } |
81 | } |