Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 9 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
OaiResumption | |
0.00% |
0 / 9 |
|
0.00% |
0 / 4 |
20 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
removeExpired | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
2 | |||
findToken | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
saveToken | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | /** |
4 | * Table Definition for oai_resumption |
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 Db_Table |
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 | |
30 | namespace VuFind\Db\Table; |
31 | |
32 | use Laminas\Db\Adapter\Adapter; |
33 | use VuFind\Db\Row\RowGateway; |
34 | use VuFind\Db\Service\DbServiceAwareInterface; |
35 | |
36 | /** |
37 | * Table Definition for oai_resumption |
38 | * |
39 | * @category VuFind |
40 | * @package Db_Table |
41 | * @author Demian Katz <demian.katz@villanova.edu> |
42 | * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License |
43 | * @link https://vufind.org Main Site |
44 | */ |
45 | class OaiResumption extends Gateway implements DbServiceAwareInterface |
46 | { |
47 | use \VuFind\Db\Service\DbServiceAwareTrait; |
48 | |
49 | /** |
50 | * Constructor |
51 | * |
52 | * @param Adapter $adapter Database adapter |
53 | * @param PluginManager $tm Table manager |
54 | * @param array $cfg Laminas configuration |
55 | * @param RowGateway $rowObj Row prototype object (null for default) |
56 | * @param string $table Name of database table to interface with |
57 | */ |
58 | public function __construct( |
59 | Adapter $adapter, |
60 | PluginManager $tm, |
61 | $cfg, |
62 | ?RowGateway $rowObj = null, |
63 | $table = 'oai_resumption' |
64 | ) { |
65 | parent::__construct($adapter, $tm, $cfg, $rowObj, $table); |
66 | } |
67 | |
68 | /** |
69 | * Remove all expired tokens from the database. |
70 | * |
71 | * @return void |
72 | */ |
73 | public function removeExpired() |
74 | { |
75 | $callback = function ($select) { |
76 | $now = date('Y-m-d H:i:s'); |
77 | $select->where->lessThanOrEqualTo('expires', $now); |
78 | }; |
79 | $this->delete($callback); |
80 | } |
81 | |
82 | /** |
83 | * Retrieve a row from the database based on primary key; return null if it |
84 | * is not found. |
85 | * |
86 | * @param string $token The resumption token to retrieve. |
87 | * |
88 | * @return ?\VuFind\Db\Row\OaiResumption |
89 | */ |
90 | public function findToken($token) |
91 | { |
92 | return $this->select(['id' => $token])->current(); |
93 | } |
94 | |
95 | /** |
96 | * Create a new resumption token |
97 | * |
98 | * @param array $params Parameters associated with the token. |
99 | * @param int $expire Expiration time for token (Unix timestamp). |
100 | * |
101 | * @return int ID of new token |
102 | * |
103 | * @deprecated Use \VuFind\Db\Service\OaiResumptionService::createAndPersistToken() |
104 | */ |
105 | public function saveToken($params, $expire) |
106 | { |
107 | return $this->getDbService(\VuFind\Db\Service\OaiResumptionServiceInterface::class) |
108 | ->createAndPersistToken($params, $expire)->getId(); |
109 | } |
110 | } |