Documentation

TextFacade

Facade for text module operations.

Provides a unified interface to all text-related use cases. Designed for backward compatibility with existing TextService callers.

Tags
since
3.0.0

Table of Contents

Properties

$archiveText  : ArchiveText
$buildTextFilters  : BuildTextFilters
$deleteText  : DeleteText
$getTextForEdit  : GetTextForEdit
$getTextForReading  : GetTextForReading
$importText  : ImportText
$listTexts  : ListTexts
$parseText  : ParseText
$sentenceService  : SentenceService
$textRepository  : TextRepositoryInterface
$updateText  : UpdateText

Methods

__construct()  : mixed
Constructor.
archiveText()  : array{sentences: int, textItems: int, archived: int}
Archive an active text.
archiveTexts()  : array{count: int}
Archive multiple texts.
buildArchivedQueryWhereClause()  : array<string|int, mixed>
Build WHERE clause for archived text query.
buildArchivedTagHavingClause()  : string
Build HAVING clause for archived text tag filtering.
buildTextQueryWhereClause()  : array<string|int, mixed>
Build WHERE clause for text query.
buildTextTagHavingClause()  : string
Build HAVING clause for text tag filtering.
checkText()  : void
Check text for parsing without saving (outputs HTML).
createText()  : array<string|int, mixed>
Create a new text.
deleteArchivedText()  : array{count: int}
Delete an archived text.
deleteArchivedTexts()  : array{count: int}
Delete multiple archived texts.
deleteText()  : array{texts: int, sentences: int, textItems: int}
Delete an active text.
deleteTexts()  : array{count: int}
Delete multiple active texts.
getArchivedTextById()  : array<string|int, mixed>|null
Get a single archived text by ID.
getArchivedTextCount()  : int
Get count of archived texts matching filters.
getArchivedTextsForLanguage()  : array{texts: array, pagination: array}
Get paginated archived texts for a specific language.
getArchivedTextsList()  : array<string|int, mixed>
Get archived texts list with pagination.
getArchivedTextsPerPage()  : int
Get archived texts per page setting.
getBasicTextsForLanguage()  : array<string|int, mixed>
Get texts for a specific language (basic version without sort).
getLanguageDataForForm()  : array<string|int, mixed>
Get language data for form.
getLanguageIdByName()  : int|null
Get language ID by name.
getLanguageSettingsForReading()  : array<string|int, mixed>|null
Get language settings for reading.
getLanguageTranslateUris()  : array<int, string>
Get Google Translate URIs by language.
getPagination()  : array<string|int, mixed>
Calculate pagination info.
getParsingPreview()  : array<string|int, mixed>
Get text parsing preview (sentences, words, unknown percent).
getTextById()  : array<string|int, mixed>|null
Get a single active text by ID.
getTextCount()  : int
Get count of active texts matching filters.
getTextDataForContent()  : array<string|int, mixed>|null
Get text data for text content display.
getTextForEdit()  : array<string|int, mixed>|null
Get text for edit form.
getTextForReading()  : array<string|int, mixed>|null
Get text data for reading interface.
getTextsForLanguage()  : array{texts: array, pagination: array}
Get paginated texts for a specific language (with sort).
getTextsForSelect()  : array<string|int, mixed>
Get texts formatted for select dropdown.
getTextsList()  : array<string|int, mixed>
Get active texts list with pagination.
getTextsPerPage()  : int
Get texts per page setting.
getTtsVoiceApi()  : string|null
Get TTS voice API for language.
rebuildTexts()  : int
Rebuild/reparse multiple texts.
saveAndReparseText()  : string
Save text and reparse (returns message only).
saveTextAndReparse()  : array{message: string, textId: int, redirect: bool}
Save text and reparse it (with additional return data).
setTermSentences()  : int
Set term sentences for words from texts.
setTermSentencesWithService()  : int
Set term sentences from texts (with SentenceService).
unarchiveText()  : array{success: bool, textId: ?int, unarchived: int, sentences: int, textItems: int, error: ?string}
Unarchive a text.
unarchiveTexts()  : array{count: int}
Unarchive multiple texts.
updateArchivedText()  : int
Update an archived text.
updateText()  : array<string|int, mixed>
Update an active text.
validateRegexQuery()  : bool
Validate regex query.
validateTextLength()  : bool
Validate text length.

Properties

Methods

__construct()

Constructor.

public __construct([TextRepositoryInterface|null $textRepository = null ][, ArchiveText|null $archiveText = null ][, BuildTextFilters|null $buildTextFilters = null ][, DeleteText|null $deleteText = null ][, GetTextForEdit|null $getTextForEdit = null ][, GetTextForReading|null $getTextForReading = null ][, ImportText|null $importText = null ][, ListTexts|null $listTexts = null ][, ParseText|null $parseText = null ][, UpdateText|null $updateText = null ][, SentenceService|null $sentenceService = null ]) : mixed
Parameters
$textRepository : TextRepositoryInterface|null = null

Text repository

$archiveText : ArchiveText|null = null

Archive use case

$buildTextFilters : BuildTextFilters|null = null

Filter builder use case

$deleteText : DeleteText|null = null

Delete use case

$getTextForEdit : GetTextForEdit|null = null

Get for edit use case

$getTextForReading : GetTextForReading|null = null

Get for reading use case

$importText : ImportText|null = null

Import use case

$listTexts : ListTexts|null = null

List use case

$parseText : ParseText|null = null

Parse use case

$updateText : UpdateText|null = null

Update use case

$sentenceService : SentenceService|null = null

Sentence service

archiveText()

Archive an active text.

public archiveText(int $textId) : array{sentences: int, textItems: int, archived: int}
Parameters
$textId : int
Return values
array{sentences: int, textItems: int, archived: int}

archiveTexts()

Archive multiple texts.

public archiveTexts(array<string|int, mixed> $textIds) : array{count: int}
Parameters
$textIds : array<string|int, mixed>
Return values
array{count: int}

buildArchivedQueryWhereClause()

Build WHERE clause for archived text query.

public buildArchivedQueryWhereClause(string $query, string $queryMode, string $regexMode) : array<string|int, mixed>
Parameters
$query : string
$queryMode : string
$regexMode : string
Return values
array<string|int, mixed>

buildArchivedTagHavingClause()

Build HAVING clause for archived text tag filtering.

public buildArchivedTagHavingClause(string|int $tag1, string|int $tag2, string $tag12) : string
Parameters
$tag1 : string|int
$tag2 : string|int
$tag12 : string
Return values
string

buildTextQueryWhereClause()

Build WHERE clause for text query.

public buildTextQueryWhereClause(string $query, string $queryMode, string $regexMode) : array<string|int, mixed>
Parameters
$query : string
$queryMode : string
$regexMode : string
Return values
array<string|int, mixed>

buildTextTagHavingClause()

Build HAVING clause for text tag filtering.

public buildTextTagHavingClause(string|int $tag1, string|int $tag2, string $tag12) : string
Parameters
$tag1 : string|int
$tag2 : string|int
$tag12 : string
Return values
string

checkText()

Check text for parsing without saving (outputs HTML).

public checkText(string $text, int $lgId) : void
Parameters
$text : string

Text to check

$lgId : int

Language ID

createText()

Create a new text.

public createText(int $lgId, string $title, string $text, string $audioUri, string $sourceUri) : array<string|int, mixed>
Parameters
$lgId : int
$title : string
$text : string
$audioUri : string
$sourceUri : string
Return values
array<string|int, mixed>

deleteArchivedText()

Delete an archived text.

public deleteArchivedText(int $textId) : array{count: int}
Parameters
$textId : int
Return values
array{count: int}

deleteArchivedTexts()

Delete multiple archived texts.

public deleteArchivedTexts(array<string|int, mixed> $textIds) : array{count: int}
Parameters
$textIds : array<string|int, mixed>
Return values
array{count: int}

deleteText()

Delete an active text.

public deleteText(int $textId) : array{texts: int, sentences: int, textItems: int}
Parameters
$textId : int
Return values
array{texts: int, sentences: int, textItems: int}

deleteTexts()

Delete multiple active texts.

public deleteTexts(array<string|int, mixed> $textIds) : array{count: int}
Parameters
$textIds : array<string|int, mixed>
Return values
array{count: int}

getArchivedTextById()

Get a single archived text by ID.

public getArchivedTextById(int $textId) : array<string|int, mixed>|null
Parameters
$textId : int
Return values
array<string|int, mixed>|null

getArchivedTextCount()

Get count of archived texts matching filters.

public getArchivedTextCount(string $whLang, string $whQuery, string $whTag) : int
Parameters
$whLang : string
$whQuery : string
$whTag : string
Return values
int

getArchivedTextsForLanguage()

Get paginated archived texts for a specific language.

public getArchivedTextsForLanguage(int $langId, int $page, int $perPage, int $sort) : array{texts: array, pagination: array}
Parameters
$langId : int

Language ID

$page : int

Page number

$perPage : int

Items per page

$sort : int

Sort option (1=title, 2=newest, 3=oldest)

Return values
array{texts: array, pagination: array}

getArchivedTextsList()

Get archived texts list with pagination.

public getArchivedTextsList(string $whLang, string $whQuery, string $whTag, int $sort, int $page, int $perPage) : array<string|int, mixed>
Parameters
$whLang : string
$whQuery : string
$whTag : string
$sort : int
$page : int
$perPage : int
Return values
array<string|int, mixed>

getArchivedTextsPerPage()

Get archived texts per page setting.

public getArchivedTextsPerPage() : int
Return values
int

getBasicTextsForLanguage()

Get texts for a specific language (basic version without sort).

public getBasicTextsForLanguage(int $languageId[, int $page = 1 ][, int $perPage = 20 ]) : array<string|int, mixed>

Note: TextService::getTextsForLanguage() has an additional sort parameter for BC. Use that method if you need sorting.

Parameters
$languageId : int
$page : int = 1
$perPage : int = 20
Return values
array<string|int, mixed>

getLanguageDataForForm()

Get language data for form.

public getLanguageDataForForm() : array<string|int, mixed>
Return values
array<string|int, mixed>

getLanguageIdByName()

Get language ID by name.

public getLanguageIdByName(string $languageName) : int|null
Parameters
$languageName : string
Return values
int|null

getLanguageSettingsForReading()

Get language settings for reading.

public getLanguageSettingsForReading(int $languageId) : array<string|int, mixed>|null
Parameters
$languageId : int
Return values
array<string|int, mixed>|null

getLanguageTranslateUris()

Get Google Translate URIs by language.

public getLanguageTranslateUris() : array<int, string>
Return values
array<int, string>

Map of language ID to translate URI

getPagination()

Calculate pagination info.

public getPagination(int $totalCount, int $currentPage, int $perPage) : array<string|int, mixed>
Parameters
$totalCount : int
$currentPage : int
$perPage : int
Return values
array<string|int, mixed>

getParsingPreview()

Get text parsing preview (sentences, words, unknown percent).

public getParsingPreview(string $text, int $languageId) : array<string|int, mixed>

Returns parsing statistics without saving. Use this for new code. TextService::checkText() is kept for BC (outputs HTML directly).

Parameters
$text : string
$languageId : int
Return values
array<string|int, mixed>

getTextById()

Get a single active text by ID.

public getTextById(int $textId) : array<string|int, mixed>|null
Parameters
$textId : int
Return values
array<string|int, mixed>|null

getTextCount()

Get count of active texts matching filters.

public getTextCount(string $whLang, string $whQuery, string $whTag) : int
Parameters
$whLang : string
$whQuery : string
$whTag : string
Return values
int

getTextDataForContent()

Get text data for text content display.

public getTextDataForContent(int $textId) : array<string|int, mixed>|null
Parameters
$textId : int

Text ID

Return values
array<string|int, mixed>|null

Text data or null if not found

getTextForEdit()

Get text for edit form.

public getTextForEdit(int $textId) : array<string|int, mixed>|null
Parameters
$textId : int
Return values
array<string|int, mixed>|null

getTextForReading()

Get text data for reading interface.

public getTextForReading(int $textId) : array<string|int, mixed>|null
Parameters
$textId : int
Return values
array<string|int, mixed>|null

getTextsForLanguage()

Get paginated texts for a specific language (with sort).

public getTextsForLanguage(int $langId[, int $page = 1 ][, int $perPage = 20 ][, int $sort = 1 ]) : array{texts: array, pagination: array}
Parameters
$langId : int

Language ID

$page : int = 1

Page number

$perPage : int = 20

Items per page

$sort : int = 1

Sort option (1=title, 2=newest, 3=oldest)

Return values
array{texts: array, pagination: array}

getTextsForSelect()

Get texts formatted for select dropdown.

public getTextsForSelect([int $languageId = 0 ][, int $maxNameLength = 30 ]) : array<string|int, mixed>
Parameters
$languageId : int = 0
$maxNameLength : int = 30
Return values
array<string|int, mixed>

getTextsList()

Get active texts list with pagination.

public getTextsList(string $whLang, string $whQuery, string $whTag, int $sort, int $page, int $perPage) : array<string|int, mixed>
Parameters
$whLang : string
$whQuery : string
$whTag : string
$sort : int
$page : int
$perPage : int
Return values
array<string|int, mixed>

getTextsPerPage()

Get texts per page setting.

public getTextsPerPage() : int
Return values
int

getTtsVoiceApi()

Get TTS voice API for language.

public getTtsVoiceApi(int $languageId) : string|null
Parameters
$languageId : int
Return values
string|null

rebuildTexts()

Rebuild/reparse multiple texts.

public rebuildTexts(array<string|int, mixed> $textIds) : int
Parameters
$textIds : array<string|int, mixed>
Return values
int

Number of texts rebuilt

saveAndReparseText()

Save text and reparse (returns message only).

public saveAndReparseText(int $textId, int $lgId, string $title, string $text, string $audioUri, string $sourceUri) : string

Use this for new code. TextService::saveTextAndReparse() returns additional data (textId, redirect) for BC with existing controllers.

Parameters
$textId : int
$lgId : int
$title : string
$text : string
$audioUri : string
$sourceUri : string
Return values
string

saveTextAndReparse()

Save text and reparse it (with additional return data).

public saveTextAndReparse(int $textId, int $lgId, string $title, string $text, string $audioUri, string $sourceUri) : array{message: string, textId: int, redirect: bool}
Parameters
$textId : int

Text ID (0 for new)

$lgId : int

Language ID

$title : string

Text title

$text : string

Text content

$audioUri : string

Audio URI

$sourceUri : string

Source URI

Return values
array{message: string, textId: int, redirect: bool}

setTermSentences()

Set term sentences for words from texts.

public setTermSentences(array<string|int, mixed> $textIds[, bool $activeOnly = false ]) : int
Parameters
$textIds : array<string|int, mixed>

Text IDs

$activeOnly : bool = false

Only update active words

Return values
int

Number of terms updated

setTermSentencesWithService()

Set term sentences from texts (with SentenceService).

public setTermSentencesWithService(array<string|int, mixed> $textIds[, bool $activeOnly = false ]) : int

Overrides the base implementation to use SentenceService for formatting.

Parameters
$textIds : array<string|int, mixed>

Text IDs to process

$activeOnly : bool = false

Only process active terms (status != 98, 99)

Return values
int

Number of terms updated

unarchiveText()

Unarchive a text.

public unarchiveText(int $archivedId) : array{success: bool, textId: ?int, unarchived: int, sentences: int, textItems: int, error: ?string}
Parameters
$archivedId : int
Return values
array{success: bool, textId: ?int, unarchived: int, sentences: int, textItems: int, error: ?string}

unarchiveTexts()

Unarchive multiple texts.

public unarchiveTexts(array<string|int, mixed> $archivedIds) : array{count: int}
Parameters
$archivedIds : array<string|int, mixed>
Return values
array{count: int}

updateArchivedText()

Update an archived text.

public updateArchivedText(int $textId, int $lgId, string $title, string $text, string $audioUri, string $sourceUri) : int
Parameters
$textId : int
$lgId : int
$title : string
$text : string
$audioUri : string
$sourceUri : string
Return values
int

Number of rows affected

updateText()

Update an active text.

public updateText(int $textId, int $lgId, string $title, string $text, string $audioUri, string $sourceUri) : array<string|int, mixed>
Parameters
$textId : int
$lgId : int
$title : string
$text : string
$audioUri : string
$sourceUri : string
Return values
array<string|int, mixed>

validateRegexQuery()

Validate regex query.

public validateRegexQuery(string $query, string $regexMode) : bool
Parameters
$query : string
$regexMode : string
Return values
bool

validateTextLength()

Validate text length.

public validateTextLength(string $text) : bool
Parameters
$text : string
Return values
bool

        
On this page

Search results