Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
5 / 5 |
|
100.00% |
4 / 4 |
CRAP | |
100.00% |
1 / 1 |
AbstractBackend | |
100.00% |
5 / 5 |
|
100.00% |
4 / 4 |
4 | |
100.00% |
1 / 1 |
setIdentifier | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getIdentifier | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setRecordCollectionFactory | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getRecordCollectionFactory | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
injectSourceIdentifier | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | /** |
4 | * Abstract backend. |
5 | * |
6 | * PHP version 8 |
7 | * |
8 | * Copyright (C) Villanova University 2010. |
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 |
25 | * @author David Maus <maus@hab.de> |
26 | * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License |
27 | * @link https://vufind.org |
28 | */ |
29 | |
30 | namespace VuFindSearch\Backend; |
31 | |
32 | use Laminas\Log\LoggerAwareInterface; |
33 | use VuFindSearch\Response\RecordCollectionFactoryInterface; |
34 | use VuFindSearch\Response\RecordCollectionInterface; |
35 | |
36 | /** |
37 | * Abstract backend. |
38 | * |
39 | * @category VuFind |
40 | * @package Search |
41 | * @author David Maus <maus@hab.de> |
42 | * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License |
43 | * @link https://vufind.org |
44 | */ |
45 | abstract class AbstractBackend implements BackendInterface, LoggerAwareInterface |
46 | { |
47 | use \VuFind\Log\LoggerAwareTrait; |
48 | |
49 | /** |
50 | * Record collection factory. |
51 | * |
52 | * @var RecordCollectionFactoryInterface |
53 | */ |
54 | protected $collectionFactory = null; |
55 | |
56 | /** |
57 | * Backend identifier. |
58 | * |
59 | * @var string |
60 | */ |
61 | protected $identifier = null; |
62 | |
63 | /** |
64 | * Set the backend identifier. |
65 | * |
66 | * @param string $identifier Backend identifier |
67 | * |
68 | * @return void |
69 | */ |
70 | public function setIdentifier($identifier) |
71 | { |
72 | $this->identifier = $identifier; |
73 | } |
74 | |
75 | /** |
76 | * Return backend identifier. |
77 | * |
78 | * @return string |
79 | */ |
80 | public function getIdentifier() |
81 | { |
82 | return $this->identifier; |
83 | } |
84 | |
85 | /** |
86 | * Set the record collection factory. |
87 | * |
88 | * @param RecordCollectionFactoryInterface $factory Factory |
89 | * |
90 | * @return void |
91 | */ |
92 | public function setRecordCollectionFactory( |
93 | RecordCollectionFactoryInterface $factory |
94 | ) { |
95 | $this->collectionFactory = $factory; |
96 | } |
97 | |
98 | /** |
99 | * Return the record collection factory. |
100 | * |
101 | * Lazy loads a generic collection factory. |
102 | * |
103 | * @return RecordCollectionFactoryInterface |
104 | */ |
105 | abstract public function getRecordCollectionFactory(); |
106 | |
107 | /// Internal API |
108 | |
109 | /** |
110 | * Inject source identifier in record collection and all contained records. |
111 | * |
112 | * @param RecordCollectionInterface $response Response |
113 | * |
114 | * @return RecordCollectionInterface |
115 | */ |
116 | protected function injectSourceIdentifier(RecordCollectionInterface $response) |
117 | { |
118 | $response->setSourceIdentifiers($this->identifier); |
119 | return $response; |
120 | } |
121 | } |