/
TagServiceInterface.php
112 lines (104 loc) · 3.75 KB
/
TagServiceInterface.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<?php
/**
* Database service interface for tags.
*
* PHP version 8
*
* Copyright (C) Villanova University 2024.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category VuFind
* @package Database
* @author Demian Katz <demian.katz@villanova.edu>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org/wiki/development:plugins:database_gateways Wiki
*/
namespace VuFind\Db\Service;
use VuFind\Db\Entity\UserEntityInterface;
/**
* Database service interface for tags.
*
* @category VuFind
* @package Database
* @author Demian Katz <demian.katz@villanova.edu>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org/wiki/development:plugins:database_gateways Wiki
*/
interface TagServiceInterface extends DbServiceInterface
{
/**
* Get statistics on use of tags.
*
* @param bool $extended Include extended (unique/anonymous) stats.
*
* @return array
*/
public function getStatistics(bool $extended = false): array;
/**
* Get the tags that match a string
*
* @param string $text Tag to look up.
*
* @return array
*/
public function matchText(string $text): array;
/**
* Get tags associated with the specified resource.
*
* @param string $id Record ID to look up
* @param string $source Source of record to look up
* @param int $limit Max. number of tags to return (0 = no limit)
* @param ?int $list ID of list to load tags from (null for no
* restriction, true for on ANY list, false for on NO list)
* @param ?int $user ID of user to load tags from (null for all users)
* @param string $sort Sort type ('count' or 'tag')
* @param ?int $userToCheck ID of user to check for ownership (this will
* not filter the result list, but rows owned by this user will have an is_me
* column set to 1)
*
* @return array
*/
public function getForResource(
string $id,
string $source = DEFAULT_SEARCH_BACKEND,
int $limit = 0,
?int $list = null,
?int $user = null,
string $sort = 'count',
?int $userToCheck = null
): array;
/**
* Add tags to the record.
*
* @param string $id Unique record ID
* @param string $source Record source
* @param UserEntityInterface $user The user adding the tag(s)
* @param string[] $tags The user-provided tag(s)
*
* @return void
*/
public function addTagsToRecord(string $id, string $source, UserEntityInterface $user, array $tags): void;
/**
* Remove tags from the record.
*
* @param string $id Unique record ID
* @param string $source Record source
* @param UserEntityInterface $user The user deleting the tag(s)
* @param string[] $tags The user-provided tag(s)
*
* @return void
*/
public function deleteTagsFromRecord(string $id, string $source, UserEntityInterface $user, array $tags): void;
}