Documentation

TagRepositoryInterface

Repository interface for Tag entity.

Defines the contract for tag persistence operations. Implementations handle specific tag types (term or text).

Tags
since
3.0.0

Table of Contents

Methods

count()  : int
Get total count of tags matching a filter.
delete()  : bool
Delete a tag by ID.
deleteAll()  : int
Delete all tags matching a filter.
deleteMultiple()  : int
Delete multiple tags by IDs.
exists()  : bool
Check if a tag exists by ID.
find()  : Tag|null
Find a tag by its ID.
findAll()  : array<string|int, Tag>
Find all tags ordered by specified column.
findByText()  : Tag|null
Find a tag by its text.
getAllTexts()  : array<string|int, string>
Get all tag texts as an array.
getOrCreate()  : int
Get or create a tag by text.
getTagType()  : TagType
Get the tag type this repository handles.
getUsageCount()  : int
Get usage count for a specific tag.
paginate()  : Tag[], usageCounts: array, totalCount: int}
Get paginated list of tags with usage counts.
save()  : void
Save a tag entity (create or update).
textExists()  : bool
Check if a tag text exists.

Methods

count()

Get total count of tags matching a filter.

public count([string $query = '' ]) : int
Parameters
$query : string = ''

Filter query (supports * wildcard)

Return values
int

delete()

Delete a tag by ID.

public delete(int $id) : bool
Parameters
$id : int

Tag ID

Return values
bool

True if deleted, false if not found

deleteAll()

Delete all tags matching a filter.

public deleteAll([string $query = '' ]) : int
Parameters
$query : string = ''

Filter query (supports * wildcard)

Return values
int

Number of deleted tags

deleteMultiple()

Delete multiple tags by IDs.

public deleteMultiple(array<string|int, int> $ids) : int
Parameters
$ids : array<string|int, int>

Tag IDs to delete

Return values
int

Number of deleted tags

exists()

Check if a tag exists by ID.

public exists(int $id) : bool
Parameters
$id : int

Tag ID

Return values
bool

find()

Find a tag by its ID.

public find(int $id) : Tag|null
Parameters
$id : int

Tag ID

Return values
Tag|null

Tag entity or null if not found

findAll()

Find all tags ordered by specified column.

public findAll([string $orderBy = 'text' ][, string $direction = 'ASC' ]) : array<string|int, Tag>
Parameters
$orderBy : string = 'text'

Column to order by ('text', 'comment', 'usage')

$direction : string = 'ASC'

Sort direction ('ASC' or 'DESC')

Return values
array<string|int, Tag>

findByText()

Find a tag by its text.

public findByText(string $text) : Tag|null
Parameters
$text : string

Tag text (case-sensitive)

Return values
Tag|null

Tag entity or null if not found

getAllTexts()

Get all tag texts as an array.

public getAllTexts() : array<string|int, string>

Used for caching and autocomplete.

Return values
array<string|int, string>

getOrCreate()

Get or create a tag by text.

public getOrCreate(string $text) : int

If tag exists, returns its ID. Otherwise creates it and returns the new ID.

Parameters
$text : string

Tag text

Return values
int

Tag ID

getUsageCount()

Get usage count for a specific tag.

public getUsageCount(int $tagId) : int

For term tags: count of words with this tag. For text tags: count of texts with this tag.

Parameters
$tagId : int

Tag ID

Return values
int

paginate()

Get paginated list of tags with usage counts.

public paginate(int $page, int $perPage[, string $query = '' ][, string $orderBy = 'text' ]) : Tag[], usageCounts: array, totalCount: int}
Parameters
$page : int

Page number (1-based)

$perPage : int

Items per page

$query : string = ''

Filter query (supports * wildcard)

$orderBy : string = 'text'

Column to order by

Return values
Tag[], usageCounts: array, totalCount: int}

textExists()

Check if a tag text exists.

public textExists(string $text[, int|null $excludeId = null ]) : bool
Parameters
$text : string

Tag text to check

$excludeId : int|null = null

Tag ID to exclude (for updates)

Return values
bool

        
On this page

Search results