VuFind API Documentation

Tags extends Gateway
in package
implements DbServiceAwareInterface Uses DbServiceAwareTrait

Table Definition for tags

Tags
category

VuFind

author

Demian Katz demian.katz@villanova.edu

license

http://opensource.org/licenses/gpl-2.0.php GNU General Public License

link

Main Site

Interfaces, Classes, Traits and Enums

DbServiceAwareInterface
Marker interface for classes that depend on the \VuFind\Db\Service\PluginManager

Table of Contents

$caseSensitive  : mixed
$dbServiceManager  : PluginManager
Database service plugin manager
$tableManager  : PluginManager
Table manager
__construct()  : mixed
Constructor
beginTransaction()  : void
Begin a database transaction.
commitTransaction()  : void
Commit a database transaction.
createRow()  : object
Create a new row.
deleteByIdArray()  : void
Delete a group of tags.
fixDuplicateTags()  : void
Repair duplicate tags in the database (if any).
getByText()  : mixed
Get the row associated with a specific tag string.
getDbService()  : T
Get a database service object.
getDbServiceManager()  : PluginManager
Get the service plugin manager. Throw an exception if it is missing.
getDbTable()  : Gateway
Get access to another table.
getDuplicates()  : mixed
Get a list of duplicate tags (this should never happen, but past bugs and the introduction of case-insensitive tags have introduced problems).
getForList()  : AbstractResultSet
Get tags assigned to a user list.
getForResource()  : array<string|int, mixed>
Get tags associated with the specified resource.
getListTagsForUser()  : AbstractResultSet
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.
getTagList()  : array<string|int, mixed>
Get a list of tags based on a sort method ($sort)
initializeFeatures()  : void
Initialize features
matchText()  : array<string|int, mixed>
Get the tags that match a string
resourceSearch()  : array<string|int, mixed>
Get all resources associated with the provided tag query.
rollBackTransaction()  : void
Roll back a database transaction.
setDbServiceManager()  : void
Set the service plugin manager.
fixDuplicateTag()  : void
Support method for fixDuplicateTags()
getIsMeSubquery()  : Select
Get a subquery used for flagging tag ownership (see getForResource).
mergeTags()  : void
Support method for fixDuplicateTag() -- merge $source into $target.

Properties

$caseSensitive

protected mixed $caseSensitive = false

Methods

__construct()

Constructor

public __construct(Adapter $adapter, PluginManager $tm, array<string|int, mixed> $cfg[, RowGateway $rowObj = null ][, bool $caseSensitive = false ][, string $table = 'tags' ]) : mixed
Parameters
$adapter : Adapter

Database adapter

$tm : PluginManager

Table manager

$cfg : array<string|int, mixed>

Laminas configuration

$rowObj : RowGateway = null

Row prototype object (null for default)

$caseSensitive : bool = false

Are tags case sensitive?

$table : string = 'tags'

Name of database table to interface with

Return values
mixed

beginTransaction()

Begin a database transaction.

public beginTransaction() : void
Tags
throws
Exception
Return values
void

commitTransaction()

Commit a database transaction.

public commitTransaction() : void
Tags
throws
Exception
Return values
void

createRow()

Create a new row.

public createRow() : object
Return values
object

deleteByIdArray()

Delete a group of tags.

public deleteByIdArray(array<string|int, mixed> $ids) : void
Parameters
$ids : array<string|int, mixed>

IDs of tags to delete.

Return values
void

fixDuplicateTags()

Repair duplicate tags in the database (if any).

public fixDuplicateTags([bool|null $caseSensitive = null ]) : void
Parameters
$caseSensitive : bool|null = null

Should tags be case sensitive? (null to use configured default)

Return values
void

getByText()

Get the row associated with a specific tag string.

public getByText(string $tag[, bool $create = true ][, bool $firstOnly = true ][, bool|null $caseSensitive = null ]) : mixed
Parameters
$tag : string

Tag to look up.

$create : bool = true

Should we create the row if it does not exist?

$firstOnly : bool = true

Should we return the first matching row (true) or the entire result set (in case of multiple matches)?

$caseSensitive : bool|null = null

Should tags be case sensitive? (null to use configured default)

Return values
mixed

Matching row/result set if found or created, null otherwise.

getDbService()

Get a database service object.

public getDbService(class-string<\VuFind\Db\Service\T> $name) : T
Parameters
$name : class-string<\VuFind\Db\Service\T>

Name of service to retrieve

Tags
template

T

Return values
T

getDbTable()

Get access to another table.

public getDbTable(string $table) : Gateway
Parameters
$table : string

Table name

Return values
Gateway

getDuplicates()

Get a list of duplicate tags (this should never happen, but past bugs and the introduction of case-insensitive tags have introduced problems).

public getDuplicates([bool|null $caseSensitive = null ]) : mixed
Parameters
$caseSensitive : bool|null = null

Should tags be case sensitive? (null to use configured default)

Return values
mixed

getForList()

Get tags assigned to a user list.

public getForList(int $listId[, int|null $userId = null ][, bool|null $caseSensitive = null ]) : AbstractResultSet
Parameters
$listId : int

List ID

$userId : int|null = null

User ID to look up (null for no filter).

$caseSensitive : bool|null = null

Should tags be case sensitive? (null to use configured default)

Return values
AbstractResultSet

getForResource()

Get tags associated with the specified resource.

public getForResource(string $id[, string $source = DEFAULT_SEARCH_BACKEND ], int $limit[, int $list = null ][, int $user = null ][, string $sort = 'count' ][, int $userToCheck = null ][, bool|null $caseSensitive = null ]) : 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)

$list : int = null

ID of list to load tags from (null for no restriction, true for on ANY list, false for on NO list)

$user : int = null

ID of user to load tags from (null for all users)

$sort : string = 'count'

Sort type ('count' or 'tag')

$userToCheck : int = 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|null = null

Should tags be case sensitive? (null to use configured default)

Return values
array<string|int, mixed>

getListTagsForUser()

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.

public getListTagsForUser(string $userId[, string $resourceId = null ][, int $listId = null ][, string $source = null ][, bool|null $caseSensitive = null ]) : AbstractResultSet
Parameters
$userId : string

User ID to look up.

$resourceId : string = null

Filter for tags tied to a specific resource (null for no filter).

$listId : int = null

Filter for tags tied to a specific list (null for no filter).

$source : string = null

Filter for tags tied to a specific record source (null for no filter).

$caseSensitive : bool|null = null

Should tags be case sensitive? (null to use configured default)

Return values
AbstractResultSet

getTagList()

Get a list of tags based on a sort method ($sort)

public getTagList(string $sort[, int $limit = 100 ][, callable $extra_where = null ][, bool|null $caseSensitive = null ]) : array<string|int, mixed>
Parameters
$sort : string

Sort/search parameter

$limit : int = 100

Maximum number of tags (default = 100, < 1 = no limit)

$extra_where : callable = null

Extra code to modify $select (null for none)

$caseSensitive : bool|null = null

Should tags be case sensitive? (null to use configured default)

Return values
array<string|int, mixed>

Tag details.

initializeFeatures()

Initialize features

public initializeFeatures(array<string|int, mixed> $cfg) : void
Parameters
$cfg : array<string|int, mixed>

Laminas configuration

Return values
void

matchText()

Get the tags that match a string

public matchText(string $text[, string $sort = 'alphabetical' ][, int $limit = 100 ][, bool|null $caseSensitive = null ]) : array<string|int, mixed>
Parameters
$text : string

Tag to look up.

$sort : string = 'alphabetical'

Sort/search parameter

$limit : int = 100

Maximum number of tags

$caseSensitive : bool|null = null

Should tags be case sensitive? (null to use configured default)

Return values
array<string|int, mixed>

Array of \VuFind\Db\Row\Tags objects

resourceSearch()

Get all resources associated with the provided tag query.

public resourceSearch(string $q[, string $source = null ][, string $sort = null ], int $offset[, int $limit = null ][, bool $fuzzy = true ][, bool|null $caseSensitive = null ]) : 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

Limit for results (null for none)

$fuzzy : bool = true

Are we doing an exact or fuzzy search?

$caseSensitive : bool|null = null

Should search be case sensitive? (null to use configured default)

Return values
array<string|int, mixed>

rollBackTransaction()

Roll back a database transaction.

public rollBackTransaction() : void
Tags
throws
Exception
Return values
void

fixDuplicateTag()

Support method for fixDuplicateTags()

protected fixDuplicateTag(string $tag[, bool|null $caseSensitive = null ]) : void
Parameters
$tag : string

Tag to deduplicate.

$caseSensitive : bool|null = null

Should tags be case sensitive? (null to use configured default)

Return values
void

getIsMeSubquery()

Get a subquery used for flagging tag ownership (see getForResource).

protected getIsMeSubquery(string $id, string $source, int $userToCheck) : Select
Parameters
$id : string

Record ID to look up

$source : string

Source of record to look up

$userToCheck : int

ID of user to check for ownership

Return values
Select

mergeTags()

Support method for fixDuplicateTag() -- merge $source into $target.

protected mergeTags(string $target, string $source) : void
Parameters
$target : string

Target ID

$source : string

Source ID

Return values
void

Search results