TagService
extends AbstractDbService
in package
implements
TagServiceInterface, DbTableAwareInterface
Uses
DbTableAwareTrait
Database service for tags.
Tags
Interfaces, Classes, Traits and Enums
- TagServiceInterface
- Database service interface for tags.
- DbTableAwareInterface
- Marker interface for classes that depend on the \VuFind\Db\Table\PluginManager
Table of Contents
- $tableManager : PluginManager
- Database table plugin manager
- createEntity() : TagsEntityInterface
- Create a new Tag entity.
- deleteOrphanedTags() : void
- Delete orphaned tags (those not present in resource_tags) from the tags table.
- getDbTable() : Gateway
- Get a database table object.
- getDbTableManager() : PluginManager
- Get the table plugin manager. Throw an exception if it is missing.
- getDuplicateTags() : array<string|int, mixed>
- Get a list of duplicate tags (this should never happen, but past bugs and the introduction of case-insensitive tags have introduced problems).
- getListTags() : array<string|int, array<string|int, mixed>>
- Get tags assigned to a user list. Returns an array of arrays with id and tag keys.
- getNonListTagsFuzzilyMatchingString() : array<string|int, mixed>
- Get the tags that match a string
- getRecordTags() : array<string|int, mixed>
- Get all tags associated with the specified record (and matching provided filters).
- getRecordTagsFromFavorites() : array<string|int, mixed>
- Get all tags from favorite lists associated with the specified record (and matching provided filters).
- getRecordTagsNotInFavorites() : array<string|int, mixed>
- Get all tags outside of favorite lists associated with the specified record (and matching provided filters).
- getResourcesMatchingTagQuery() : array<string|int, mixed>
- Get all resources associated with the provided tag query.
- getStatistics() : array<string|int, mixed>
- Get statistics on use of tags.
- getTagBrowseList() : array<string|int, mixed>
- Get a list of tags for the browse interface.
- getTagById() : TagsEntityInterface|null
- Retrieve a tag by ID.
- getTagByText() : array<string|int, TagsEntityInterface>
- Get the first available matching tag by text; return null if no match is found.
- getTagsByText() : array<string|int, TagsEntityInterface>
- Get all matching tags by text. Normally, 0 or 1 results will be retrieved, but more may be retrieved under exceptional circumstances (e.g. if retrieving case-insensitively after storing data case-sensitively).
- getUserTagsFromFavorites() : array<string|int, mixed>
- Get a list of all tags generated by the user in favorites lists. Note that the returned list WILL NOT include tags attached to records that are not saved in favorites lists. Returns an array of arrays with id and tag keys.
- persistEntity() : void
- Persist an entity.
- setDbTableManager() : void
- Set the table plugin manager.
Properties
$tableManager
Database table plugin manager
protected
PluginManager
$tableManager
Methods
createEntity()
Create a new Tag entity.
public
createEntity() : TagsEntityInterface
Return values
TagsEntityInterface —deleteOrphanedTags()
Delete orphaned tags (those not present in resource_tags) from the tags table.
public
deleteOrphanedTags() : void
Return values
void —getDbTable()
Get a database table object.
public
getDbTable(string $table) : Gateway
Parameters
- $table : string
-
Table to load.
Return values
Gateway —getDbTableManager()
Get the table plugin manager. Throw an exception if it is missing.
public
getDbTableManager() : PluginManager
Tags
Return values
PluginManager —getDuplicateTags()
Get a list of duplicate tags (this should never happen, but past bugs and the introduction of case-insensitive tags have introduced problems).
public
getDuplicateTags([bool $caseSensitive = false ]) : array<string|int, mixed>
Parameters
- $caseSensitive : bool = false
-
Treat tags as case-sensitive?
Return values
array<string|int, mixed> —getListTags()
Get tags assigned to a user list. Returns an array of arrays with id and tag keys.
public
getListTags(UserListEntityInterface|int $listOrId[, UserEntityInterface|int|null $userOrId = null ][, bool $caseSensitive = false ]) : array<string|int, array<string|int, mixed>>
Parameters
- $listOrId : UserListEntityInterface|int
-
List ID or entity
- $userOrId : UserEntityInterface|int|null = null
-
User ID or entity to look up (null for no filter).
- $caseSensitive : bool = false
-
Treat tags as case-sensitive?
Return values
array<string|int, array<string|int, mixed>> —getNonListTagsFuzzilyMatchingString()
Get the tags that match a string
public
getNonListTagsFuzzilyMatchingString(string $text[, string $sort = 'alphabetical' ][, int $limit = 100 ][, bool $caseSensitive = false ]) : array<string|int, mixed>
Parameters
- $text : string
-
Tag to look up.
- $sort : string = 'alphabetical'
-
Sort type
- $limit : int = 100
-
Maximum results to retrieve
- $caseSensitive : bool = false
-
Should tags be treated as case-sensitive?
Return values
array<string|int, mixed> —getRecordTags()
Get all tags associated with the specified record (and matching provided filters).
public
getRecordTags(string $id[, string $source = DEFAULT_SEARCH_BACKEND ], int $limit[, UserListEntityInterface|int|null $listOrId = null ][, UserEntityInterface|int|null $userOrId = null ][, string $sort = 'count' ][, UserEntityInterface|int|null $ownerOrId = null ][, bool $caseSensitive = false ]) : array<string|int, mixed>
Parameters
- $id : string
-
Record ID to look up
- $source : string = DEFAULT_SEARCH_BACKEND
-
Source of record to look up
- $limit : int
-
Max. number of tags to return (0 = no limit)
- $listOrId : UserListEntityInterface|int|null = null
-
ID of list to load tags from (null for no restriction)
- $userOrId : UserEntityInterface|int|null = null
-
ID of user to load tags from (null for all users)
- $sort : string = 'count'
-
Sort type ('count' or 'tag')
- $ownerOrId : UserEntityInterface|int|null = null
-
ID of user to check for ownership
- $caseSensitive : bool = false
-
Treat tags as case-sensitive?
Return values
array<string|int, mixed> —getRecordTagsFromFavorites()
Get all tags from favorite lists associated with the specified record (and matching provided filters).
public
getRecordTagsFromFavorites(string $id[, string $source = DEFAULT_SEARCH_BACKEND ], int $limit[, UserListEntityInterface|int|null $listOrId = null ][, UserEntityInterface|int|null $userOrId = null ][, string $sort = 'count' ][, UserEntityInterface|int|null $ownerOrId = null ][, bool $caseSensitive = false ]) : array<string|int, mixed>
Parameters
- $id : string
-
Record ID to look up
- $source : string = DEFAULT_SEARCH_BACKEND
-
Source of record to look up
- $limit : int
-
Max. number of tags to return (0 = no limit)
- $listOrId : UserListEntityInterface|int|null = null
-
ID of list to load tags from (null for tags that are associated with ANY list, but excluding non-list tags)
- $userOrId : UserEntityInterface|int|null = null
-
ID of user to load tags from (null for all users)
- $sort : string = 'count'
-
Sort type ('count' or 'tag')
- $ownerOrId : UserEntityInterface|int|null = null
-
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)
- $caseSensitive : bool = false
-
Treat tags as case-sensitive?
Return values
array<string|int, mixed> —getRecordTagsNotInFavorites()
Get all tags outside of favorite lists associated with the specified record (and matching provided filters).
public
getRecordTagsNotInFavorites(string $id[, string $source = DEFAULT_SEARCH_BACKEND ], int $limit[, UserEntityInterface|int|null $userOrId = null ][, string $sort = 'count' ][, UserEntityInterface|int|null $ownerOrId = null ][, bool $caseSensitive = false ]) : array<string|int, mixed>
Parameters
- $id : string
-
Record ID to look up
- $source : string = DEFAULT_SEARCH_BACKEND
-
Source of record to look up
- $limit : int
-
Max. number of tags to return (0 = no limit)
- $userOrId : UserEntityInterface|int|null = null
-
User entity/ID to load tags from (null for all users)
- $sort : string = 'count'
-
Sort type ('count' or 'tag')
- $ownerOrId : UserEntityInterface|int|null = null
-
Entity/ID representing 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)
- $caseSensitive : bool = false
-
Treat tags as case-sensitive?
Return values
array<string|int, mixed> —getResourcesMatchingTagQuery()
Get all resources associated with the provided tag query.
public
getResourcesMatchingTagQuery(string $q[, string $source = null ][, string $sort = null ], int $offset[, int|null $limit = null ][, bool $fuzzy = true ][, bool|null $caseSensitive = false ]) : array<string|int, mixed>
Parameters
- $q : string
-
Search query
- $source : string = null
-
Record source (optional limiter)
- $sort : string = null
-
Resource field to sort on (optional)
- $offset : int
-
Offset for results
- $limit : int|null = null
-
Limit for results (null for none)
- $fuzzy : bool = true
-
Are we doing an exact (false) or fuzzy (true) search?
- $caseSensitive : bool|null = false
-
Should search be case sensitive? (Ignored when fuzzy = true)
Return values
array<string|int, mixed> —getStatistics()
Get statistics on use of tags.
public
getStatistics([bool $extended = false ][, bool $caseSensitiveTags = false ]) : array<string|int, mixed>
Parameters
- $extended : bool = false
-
Include extended (unique/anonymous) stats.
- $caseSensitiveTags : bool = false
-
Should we treat tags case-sensitively?
Return values
array<string|int, mixed> —getTagBrowseList()
Get a list of tags for the browse interface.
public
getTagBrowseList(string $sort, int $limit[, bool $caseSensitive = false ]) : array<string|int, mixed>
Parameters
- $sort : string
-
Sort/search parameter
- $limit : int
-
Maximum number of tags (default = 100, < 1 = no limit)
- $caseSensitive : bool = false
-
Treat tags as case-sensitive?
Return values
array<string|int, mixed> —getTagById()
Retrieve a tag by ID.
public
getTagById(int $id) : TagsEntityInterface|null
Parameters
- $id : int
-
Tag ID
Return values
TagsEntityInterface|null —getTagByText()
Get the first available matching tag by text; return null if no match is found.
public
getTagByText(string $text[, bool $caseSensitive = false ]) : array<string|int, TagsEntityInterface>
Parameters
- $text : string
-
Tag text to match
- $caseSensitive : bool = false
-
Should tags be retrieved case-sensitively?
Return values
array<string|int, TagsEntityInterface> —getTagsByText()
Get all matching tags by text. Normally, 0 or 1 results will be retrieved, but more may be retrieved under exceptional circumstances (e.g. if retrieving case-insensitively after storing data case-sensitively).
public
getTagsByText(string $text[, bool $caseSensitive = false ]) : array<string|int, TagsEntityInterface>
Parameters
- $text : string
-
Tag text to match
- $caseSensitive : bool = false
-
Should tags be retrieved case-sensitively?
Return values
array<string|int, TagsEntityInterface> —getUserTagsFromFavorites()
Get a list of all tags generated by the user in favorites lists. Note that the returned list WILL NOT include tags attached to records that are not saved in favorites lists. Returns an array of arrays with id and tag keys.
public
getUserTagsFromFavorites(UserEntityInterface|int $userOrId[, UserListEntityInterface|int|null $listOrId = null ][, string|null $recordId = null ][, string|null $source = null ][, bool $caseSensitive = false ]) : array<string|int, mixed>
Parameters
- $userOrId : UserEntityInterface|int
-
User ID to look up.
- $listOrId : UserListEntityInterface|int|null = null
-
Filter for tags tied to a specific list (null for no filter).
- $recordId : string|null = null
-
Filter for tags tied to a specific resource (null for no filter).
- $source : string|null = null
-
Filter for tags tied to a specific record source (null for no filter).
- $caseSensitive : bool = false
-
Treat tags as case-sensitive?
Return values
array<string|int, mixed> —persistEntity()
Persist an entity.
public
persistEntity(EntityInterface $entity) : void
Parameters
- $entity : EntityInterface
-
Entity to persist.
Return values
void —setDbTableManager()
Set the table plugin manager.
public
setDbTableManager(PluginManager $manager) : void
Parameters
- $manager : PluginManager
-
Plugin manager