ResourceTagsService
extends AbstractDbService
in package
implements
ResourceTagsServiceInterface, TransactionInterface, DbTableAwareInterface
Uses
DbTableAwareTrait
Database service for resource_tags.
Tags
Interfaces, Classes, Traits and Enums
- ResourceTagsServiceInterface
- Database service interface for resource_tags.
- TransactionInterface
- Interface for exposing the database transaction functionality.
- DbTableAwareInterface
- Marker interface for classes that depend on the \VuFind\Db\Table\PluginManager
Table of Contents
- $tableManager : PluginManager
- Database table plugin manager
- assignAnonymousTags() : void
- Assign anonymous tags to the specified user.
- beginTransaction() : void
- Begin a database transaction.
- changeResourceId() : void
- Change all matching rows to use the new resource ID instead of the old one (called when an ID changes).
- commitTransaction() : void
- Commit a database transaction.
- createEntity() : ResourceTagsEntityInterface
- Create a ResourceTagsEntityInterface object.
- createLink() : void
- Create a resource_tags row linking the specified resources
- deduplicate() : void
- Deduplicate rows (sometimes necessary after merging foreign key IDs).
- deleteLinksByResourceTagsIdArray() : int
- Remove links from the resource_tags table based on an array of IDs.
- deleteResourceTags() : int
- Delete resource tags rows matching specified filter(s). Return count of IDs deleted.
- destroyAllListResourceTagsLinksForUser() : void
- Unlink all tag rows associated with favorite lists for the specified resource and user. Tags added directly to records outside of favorites will not be impacted.
- destroyNonListResourceTagsLinksForUser() : void
- Unlink tag rows that are not associated with a favorite list for the specified resource and user.
- destroyResourceTagsLinksForUser() : void
- Unlink tag rows for the specified resource and user.
- destroyUserListLinks() : void
- Unlink rows for the specified user list. This removes tags ON THE LIST ITSELF, not tags on resources within the list.
- getAnonymousCount() : int
- Get count of anonymous tags
- getDbTable() : Gateway
- Get a database table object.
- getDbTableManager() : PluginManager
- Get the table plugin manager. Throw an exception if it is missing.
- getResourceTagsPaginator() : Paginator
- Get Resource Tags Paginator
- getUniqueResources() : array<string|int, array<string|int, mixed>>
- Gets unique tagged resources from the database.
- getUniqueTags() : array<string|int, array<string|int, mixed>>
- Gets unique tags from the database.
- getUniqueUsers() : array<string|int, array<string|int, mixed>>
- Gets unique users from the database.
- persistEntity() : void
- Persist an entity.
- rollBackTransaction() : void
- Roll back a database transaction.
- setDbTableManager() : void
- Set the table plugin manager.
Properties
$tableManager
Database table plugin manager
protected
PluginManager
$tableManager
Methods
assignAnonymousTags()
Assign anonymous tags to the specified user.
public
assignAnonymousTags(UserEntityInterface|int $userOrId) : void
Parameters
- $userOrId : UserEntityInterface|int
-
User entity or ID to own anonymous tags.
Return values
void —beginTransaction()
Begin a database transaction.
public
beginTransaction() : void
Tags
Return values
void —changeResourceId()
Change all matching rows to use the new resource ID instead of the old one (called when an ID changes).
public
changeResourceId(int $old, int $new) : void
Parameters
- $old : int
-
Original resource ID
- $new : int
-
New resource ID
Return values
void —commitTransaction()
Commit a database transaction.
public
commitTransaction() : void
Tags
Return values
void —createEntity()
Create a ResourceTagsEntityInterface object.
public
createEntity() : ResourceTagsEntityInterface
Return values
ResourceTagsEntityInterface —createLink()
Create a resource_tags row linking the specified resources
public
createLink(ResourceEntityInterface|int|null $resourceOrId, TagsEntityInterface|int $tagOrId[, UserEntityInterface|int|null $userOrId = null ][, UserListEntityInterface|int|null $listOrId = null ][, DateTime|null $posted = null ]) : void
Parameters
- $resourceOrId : ResourceEntityInterface|int|null
-
Resource entity or ID to link up (optional)
- $tagOrId : TagsEntityInterface|int
-
Tag entity or ID to link up
- $userOrId : UserEntityInterface|int|null = null
-
User entity or ID creating link (optional but recommended)
- $listOrId : UserListEntityInterface|int|null = null
-
List entity or ID to link up (optional)
- $posted : DateTime|null = null
-
Posted date (optional -- omit for current)
Return values
void —deduplicate()
Deduplicate rows (sometimes necessary after merging foreign key IDs).
public
deduplicate() : void
Return values
void —deleteLinksByResourceTagsIdArray()
Remove links from the resource_tags table based on an array of IDs.
public
deleteLinksByResourceTagsIdArray(array<string|int, string> $ids) : int
Parameters
- $ids : array<string|int, string>
-
Identifiers from resource_tags to delete.
Return values
int —Count of $ids
deleteResourceTags()
Delete resource tags rows matching specified filter(s). Return count of IDs deleted.
public
deleteResourceTags([int|null $userId = null ][, int|null $resourceId = null ][, int|null $tagId = null ]) : int
Parameters
- $userId : int|null = null
-
ID of user (null for any)
- $resourceId : int|null = null
-
ID of the resource (null for any)
- $tagId : int|null = null
-
ID of the tag (null for any)
Return values
int —destroyAllListResourceTagsLinksForUser()
Unlink all tag rows associated with favorite lists for the specified resource and user. Tags added directly to records outside of favorites will not be impacted.
public
destroyAllListResourceTagsLinksForUser(int|array<string|int, int>|null $resourceId, UserEntityInterface|int $userOrId[, int|array<string|int, int>|null $tagId = null ]) : void
Parameters
- $resourceId : int|array<string|int, int>|null
-
ID (or array of IDs) of resource(s) to unlink (null for ALL matching resources)
- $userOrId : UserEntityInterface|int
-
ID or entity representing user
- $tagId : int|array<string|int, int>|null = null
-
ID or array of IDs of tag(s) to unlink (null for ALL matching tags)
Return values
void —destroyNonListResourceTagsLinksForUser()
Unlink tag rows that are not associated with a favorite list for the specified resource and user.
public
destroyNonListResourceTagsLinksForUser(int|array<string|int, int>|null $resourceId, UserEntityInterface|int $userOrId[, int|array<string|int, int>|null $tagId = null ]) : void
Parameters
- $resourceId : int|array<string|int, int>|null
-
ID (or array of IDs) of resource(s) to unlink (null for ALL matching resources)
- $userOrId : UserEntityInterface|int
-
ID or entity representing user
- $tagId : int|array<string|int, int>|null = null
-
ID or array of IDs of tag(s) to unlink (null for ALL matching tags)
Return values
void —destroyResourceTagsLinksForUser()
Unlink tag rows for the specified resource and user.
public
destroyResourceTagsLinksForUser(int|array<string|int, int>|null $resourceId, UserEntityInterface|int $userOrId[, UserListEntityInterface|int|null $listOrId = null ][, int|array<string|int, int>|null $tagId = null ]) : void
Parameters
- $resourceId : int|array<string|int, int>|null
-
ID (or array of IDs) of resource(s) to unlink (null for ALL matching resources)
- $userOrId : UserEntityInterface|int
-
ID or entity representing user
- $listOrId : UserListEntityInterface|int|null = null
-
ID of list to unlink (null for ALL matching tags)
- $tagId : int|array<string|int, int>|null = null
-
ID or array of IDs of tag(s) to unlink (null for ALL matching tags)
Return values
void —destroyUserListLinks()
Unlink rows for the specified user list. This removes tags ON THE LIST ITSELF, not tags on resources within the list.
public
destroyUserListLinks(UserListEntityInterface|int $listOrId, UserEntityInterface|int $userOrId[, int|array<string|int, int>|null $tagId = null ]) : void
Parameters
- $listOrId : UserListEntityInterface|int
-
ID or entity representing list
- $userOrId : UserEntityInterface|int
-
ID or entity representing user
- $tagId : int|array<string|int, int>|null = null
-
ID or array of IDs of tag(s) to unlink (null for ALL matching tags)
Return values
void —getAnonymousCount()
Get count of anonymous tags
public
getAnonymousCount() : int
Return values
int —count
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 —getResourceTagsPaginator()
Get Resource Tags Paginator
public
getResourceTagsPaginator([int|null $userId = null ][, int|null $resourceId = null ][, int|null $tagId = null ][, string|null $order = null ][, int|null $page = null ][, int $limit = 20 ][, bool $caseSensitiveTags = false ]) : Paginator
Parameters
- $userId : int|null = null
-
ID of user (null for any)
- $resourceId : int|null = null
-
ID of the resource (null for any)
- $tagId : int|null = null
-
ID of the tag (null for any)
- $order : string|null = null
-
The order in which to return the data
- $page : int|null = null
-
The page number to select
- $limit : int = 20
-
The number of items to fetch
- $caseSensitiveTags : bool = false
-
Should we treat tags as case-sensitive?
Return values
Paginator —getUniqueResources()
Gets unique tagged resources from the database.
public
getUniqueResources([int|null $userId = null ][, int|null $resourceId = null ][, int|null $tagId = null ]) : array<string|int, array<string|int, mixed>>
Parameters
- $userId : int|null = null
-
ID of user (null for any)
- $resourceId : int|null = null
-
ID of the resource (null for any)
- $tagId : int|null = null
-
ID of the tag (null for any)
Return values
array<string|int, array<string|int, mixed>> —getUniqueTags()
Gets unique tags from the database.
public
getUniqueTags([int|null $userId = null ][, int|null $resourceId = null ][, int|null $tagId = null ][, bool $caseSensitive = false ]) : array<string|int, array<string|int, mixed>>
Parameters
- $userId : int|null = null
-
ID of user (null for any)
- $resourceId : int|null = null
-
ID of the resource (null for any)
- $tagId : int|null = null
-
ID of the tag (null for any)
- $caseSensitive : bool = false
-
Should we treat tags in a case-sensitive manner?
Return values
array<string|int, array<string|int, mixed>> —getUniqueUsers()
Gets unique users from the database.
public
getUniqueUsers([int|null $userId = null ][, int|null $resourceId = null ][, int|null $tagId = null ]) : array<string|int, array<string|int, mixed>>
Parameters
- $userId : int|null = null
-
ID of user (null for any)
- $resourceId : int|null = null
-
ID of the resource (null for any)
- $tagId : int|null = null
-
ID of the tag (null for any)
Return values
array<string|int, array<string|int, mixed>> —persistEntity()
Persist an entity.
public
persistEntity(EntityInterface $entity) : void
Parameters
- $entity : EntityInterface
-
Entity to persist.
Return values
void —rollBackTransaction()
Roll back a database transaction.
public
rollBackTransaction() : void
Tags
Return values
void —setDbTableManager()
Set the table plugin manager.
public
setDbTableManager(PluginManager $manager) : void
Parameters
- $manager : PluginManager
-
Plugin manager