Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
14.29% |
1 / 7 |
|
20.00% |
1 / 5 |
CRAP | |
0.00% |
0 / 1 |
ExternalSession | |
14.29% |
1 / 7 |
|
20.00% |
1 / 5 |
20.74 | |
0.00% |
0 / 1 |
__construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
addSessionMapping | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
getByExternalSessionId | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
destroySession | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
expirationCallback | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | /** |
4 | * Table Definition for external_session |
5 | * |
6 | * PHP version 8 |
7 | * |
8 | * Copyright (C) Villanova University 2010. |
9 | * Copyright (C) The National Library of Finland 2016. |
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 Db_Table |
26 | * @author Demian Katz <demian.katz@villanova.edu> |
27 | * @author Ere Maijala <ere.maijala@helsinki.fi> |
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\Db\Table; |
33 | |
34 | use Laminas\Db\Adapter\Adapter; |
35 | use VuFind\Db\Row\RowGateway; |
36 | use VuFind\Db\Service\DbServiceAwareInterface; |
37 | use VuFind\Db\Service\DbServiceAwareTrait; |
38 | use VuFind\Db\Service\ExternalSessionServiceInterface; |
39 | |
40 | /** |
41 | * Table Definition for external_session |
42 | * |
43 | * @category VuFind |
44 | * @package Db_Table |
45 | * @author Demian Katz <demian.katz@villanova.edu> |
46 | * @author Ere Maijala <ere.maijala@helsinki.fi> |
47 | * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License |
48 | * @link https://vufind.org Main Site |
49 | */ |
50 | class ExternalSession extends Gateway implements DbServiceAwareInterface |
51 | { |
52 | use DbServiceAwareTrait; |
53 | use ExpirationTrait; |
54 | |
55 | /** |
56 | * Constructor |
57 | * |
58 | * @param Adapter $adapter Database adapter |
59 | * @param PluginManager $tm Table manager |
60 | * @param array $cfg Laminas configuration |
61 | * @param RowGateway $rowObj Row prototype object (null for default) |
62 | * @param string $table Name of database table to interface with |
63 | */ |
64 | public function __construct( |
65 | Adapter $adapter, |
66 | PluginManager $tm, |
67 | $cfg, |
68 | ?RowGateway $rowObj = null, |
69 | $table = 'external_session' |
70 | ) { |
71 | parent::__construct($adapter, $tm, $cfg, $rowObj, $table); |
72 | } |
73 | |
74 | /** |
75 | * Add a mapping between local and external session id's |
76 | * |
77 | * @param string $localSessionId Local (VuFind) session id |
78 | * @param string $externalSessionId External session id |
79 | * |
80 | * @return void |
81 | * |
82 | * @deprecated Use ExternalSessionServiceInterface::addSessionMapping() |
83 | */ |
84 | public function addSessionMapping($localSessionId, $externalSessionId) |
85 | { |
86 | $this->getDbService(ExternalSessionServiceInterface::class) |
87 | ->addSessionMapping($localSessionId, $externalSessionId); |
88 | } |
89 | |
90 | /** |
91 | * Retrieve an object from the database based on an external session ID |
92 | * |
93 | * @param string $sid External session ID to retrieve |
94 | * |
95 | * @return ?\VuFind\Db\Row\ExternalSession |
96 | * |
97 | * @deprecated Use ExternalSessionServiceInterface::getAllByExternalSessionId() |
98 | */ |
99 | public function getByExternalSessionId($sid) |
100 | { |
101 | $sessions = $this->getDbService(ExternalSessionServiceInterface::class)->getAllByExternalSessionId($sid); |
102 | return $sessions[0] ?? null; |
103 | } |
104 | |
105 | /** |
106 | * Destroy data for the given session ID. |
107 | * |
108 | * @param string $sid Session ID to erase |
109 | * |
110 | * @return void |
111 | * |
112 | * @deprecated Use ExternalSessionServiceInterface::destroySession() |
113 | */ |
114 | public function destroySession($sid) |
115 | { |
116 | $this->getDbService(ExternalSessionServiceInterface::class)->destroySession($sid); |
117 | } |
118 | |
119 | /** |
120 | * Update the select statement to find records to delete. |
121 | * |
122 | * @param Select $select Select clause |
123 | * @param string $dateLimit Date threshold of an "expired" record in format |
124 | * 'Y-m-d H:i:s'. |
125 | * |
126 | * @return void |
127 | */ |
128 | protected function expirationCallback($select, $dateLimit) |
129 | { |
130 | $select->where->lessThan('created', $dateLimit); |
131 | } |
132 | } |