TextCreationInterface
in
Interface for creating texts from feed articles.
This port allows the Feed module to create texts without directly depending on TextService/TextRepository. The infrastructure layer provides an adapter implementation.
Tags
Table of Contents
Methods
- archiveOldTexts() : array{archived: int, sentences: int, textitems: int}
- Archive old texts to maintain max texts limit.
- countTextsWithTag() : int
- Count texts with the given tag.
- createText() : int
- Create a text from extracted article content.
- sourceUriExists() : bool
- Check if a text with the given source URI already exists.
Methods
archiveOldTexts()
Archive old texts to maintain max texts limit.
public
archiveOldTexts(string $tagName, int $maxTexts) : array{archived: int, sentences: int, textitems: int}
Archives the oldest texts with the given tag until the count is at or below maxTexts.
Parameters
- $tagName : string
-
Tag name to filter by
- $maxTexts : int
-
Maximum number of texts to keep
Return values
array{archived: int, sentences: int, textitems: int}countTextsWithTag()
Count texts with the given tag.
public
countTextsWithTag(string $tagName) : int
Parameters
- $tagName : string
-
Tag name
Return values
intcreateText()
Create a text from extracted article content.
public
createText(int $languageId, string $title, string $text, string $audioUri, string $sourceUri, string $tagName) : int
The implementation should:
- Insert the text into the texts table
- Parse the text into sentences and textitems
- Create/find the tag and associate it with the text
Parameters
- $languageId : int
-
Language ID for the text
- $title : string
-
Text title
- $text : string
-
Text content
- $audioUri : string
-
Audio URI (optional, empty string if none)
- $sourceUri : string
-
Source URI (the article link)
- $tagName : string
-
Tag name to apply to the text
Return values
int —The newly created text ID
sourceUriExists()
Check if a text with the given source URI already exists.
public
sourceUriExists(string $sourceUri) : bool
Parameters
- $sourceUri : string
-
Source URI to check
Return values
bool —True if a text or archived text exists with this source URI