TextRepositoryInterface
in
Repository interface for Text entities.
This is a domain port defining the contract for text persistence. Infrastructure implementations (e.g., MySqlTextRepository) provide the actual database access.
Tags
Table of Contents
Methods
- countByLanguage() : int
- Count texts for a specific language.
- delete() : bool
- Delete a text by its ID.
- exists() : bool
- Check if a text exists.
- find() : Text|null
- Find a text by its ID.
- findAll() : array<string|int, Text>
- Find all texts.
- findByLanguage() : array<string|int, Text>
- Find all texts for a specific language.
- findByTitle() : Text|null
- Find a text by title within a language.
- findPaginated() : Text[], total: int, page: int, per_page: int, total_pages: int}
- Get texts with pagination.
- getBasicInfo() : array{id: int, title: string, language_id: int, has_media: bool, has_annotation: bool}|null
- Get basic text info (minimal data for lists).
- getForSelect() : array<int, array{id: int, title: string, language_id: int}>
- Get texts formatted for select dropdown options.
- getNextTextId() : int|null
- Get the next text ID in the language.
- getPreviousTextId() : int|null
- Get the previous text ID in the language.
- save() : int
- Save a text entity.
- titleExists() : bool
- Check if a title exists within a language.
- updateAudioPosition() : bool
- Update the audio position for a text.
- updatePosition() : bool
- Update the reading position for a text.
Methods
countByLanguage()
Count texts for a specific language.
public
countByLanguage(int $languageId) : int
Parameters
- $languageId : int
-
Language ID
Return values
intdelete()
Delete a text by its ID.
public
delete(int $id) : bool
Parameters
- $id : int
-
Text ID
Return values
bool —True if deleted, false if not found
exists()
Check if a text exists.
public
exists(int $id) : bool
Parameters
- $id : int
-
Text ID
Return values
boolfind()
Find a text by its ID.
public
find(int $id) : Text|null
Parameters
- $id : int
-
Text ID
Return values
Text|null —The text entity or null if not found
findAll()
Find all texts.
public
findAll() : array<string|int, Text>
Return values
array<string|int, Text>findByLanguage()
Find all texts for a specific language.
public
findByLanguage(int $languageId[, string|null $orderBy = 'TxTitle' ][, string $direction = 'ASC' ]) : array<string|int, Text>
Parameters
- $languageId : int
-
Language ID
- $orderBy : string|null = 'TxTitle'
-
Column to order by
- $direction : string = 'ASC'
-
Sort direction (ASC/DESC)
Return values
array<string|int, Text>findByTitle()
Find a text by title within a language.
public
findByTitle(int $languageId, string $title) : Text|null
Parameters
- $languageId : int
-
Language ID
- $title : string
-
Text title
Return values
Text|nullfindPaginated()
Get texts with pagination.
public
findPaginated([int $languageId = 0 ][, int $page = 1 ][, int $perPage = 20 ][, string $orderBy = 'TxTitle' ][, string $direction = 'ASC' ]) : Text[], total: int, page: int, per_page: int, total_pages: int}
Parameters
- $languageId : int = 0
-
Language ID (0 for all languages)
- $page : int = 1
-
Page number (1-based)
- $perPage : int = 20
-
Items per page
- $orderBy : string = 'TxTitle'
-
Column to order by
- $direction : string = 'ASC'
-
Sort direction (ASC/DESC)
Return values
Text[], total: int, page: int, per_page: int, total_pages: int}getBasicInfo()
Get basic text info (minimal data for lists).
public
getBasicInfo(int $textId) : array{id: int, title: string, language_id: int, has_media: bool, has_annotation: bool}|null
Parameters
- $textId : int
-
Text ID
Return values
array{id: int, title: string, language_id: int, has_media: bool, has_annotation: bool}|nullgetForSelect()
Get texts formatted for select dropdown options.
public
getForSelect([int $languageId = 0 ][, int $maxNameLength = 40 ]) : array<int, array{id: int, title: string, language_id: int}>
Parameters
- $languageId : int = 0
-
Language ID (0 for all languages)
- $maxNameLength : int = 40
-
Maximum title length before truncation
Return values
array<int, array{id: int, title: string, language_id: int}>getNextTextId()
Get the next text ID in the language.
public
getNextTextId(int $textId, int $languageId) : int|null
Parameters
- $textId : int
-
Current text ID
- $languageId : int
-
Language ID
Return values
int|null —Next text ID or null
getPreviousTextId()
Get the previous text ID in the language.
public
getPreviousTextId(int $textId, int $languageId) : int|null
Parameters
- $textId : int
-
Current text ID
- $languageId : int
-
Language ID
Return values
int|null —Previous text ID or null
save()
Save a text entity.
public
save(Text $entity) : int
Inserts if new, updates if existing.
Parameters
- $entity : Text
-
The text entity to save
Return values
int —The text ID (newly generated for inserts)
titleExists()
Check if a title exists within a language.
public
titleExists(int $languageId, string $title[, int|null $excludeId = null ]) : bool
Parameters
- $languageId : int
-
Language ID
- $title : string
-
Text title
- $excludeId : int|null = null
-
Text ID to exclude (for updates)
Return values
boolupdateAudioPosition()
Update the audio position for a text.
public
updateAudioPosition(int $textId, float $position) : bool
Parameters
- $textId : int
-
Text ID
- $position : float
-
New audio position in seconds
Return values
bool —True if updated
updatePosition()
Update the reading position for a text.
public
updatePosition(int $textId, int $position) : bool
Parameters
- $textId : int
-
Text ID
- $position : int
-
New reading position
Return values
bool —True if updated