Documentation

LanguageApiHandler
in package
implements ApiRoutableInterface uses ApiRoutableTrait

Handler for language-related API operations.

Tags
since
3.0.0

Table of Contents

Interfaces

ApiRoutableInterface
Interface for API handlers that participate in route dispatch.

Properties

$languageFacade  : LanguageFacade
$sentenceService  : SentenceService
$similarTermsService  : FindSimilarTerms

Methods

__construct()  : mixed
Constructor - initialize services.
formatCreate()  : array{success: bool, id?: int, error?: string}
Format response for creating a new language.
formatDelete()  : array{success: bool, error?: string, relatedData?: array{texts: int, archivedTexts: int, words: int, feeds: int}}
Format response for deleting a language.
formatGetAll()  : array{languages: array, currentLanguageId: int}
Format response for getting all languages with stats.
formatGetDefinitions()  : array{definitions: array}
Format response for getting all language definitions (presets).
formatGetOne()  : array<string|int, mixed>|null
Format response for getting a single language.
formatGetStats()  : array{texts: int, archivedTexts: int, words: int, feeds: int}
Format response for getting language stats.
formatLanguagesWithArchivedTexts()  : array{languages: array}
Format response for languages with archived text counts.
formatLanguagesWithTexts()  : array{languages: array}
Format response for languages with text counts.
formatPhoneticReading()  : array{phonetic_reading: string}
Format response for phonetic reading.
formatReadingConfiguration()  : array<string|int, mixed|string>
Format response for reading configuration.
formatRefresh()  : array{success: bool, sentencesDeleted?: int, textItemsDeleted?: int, sentencesAdded?: int, textItemsAdded?: int}
Format response for refreshing (reparsing) a language's texts.
formatSentencesWithNewTerm()  : array<string|int, mixed>
Format response for sentences with new term.
formatSentencesWithRegisteredTerm()  : array<string|int, mixed>
Format response for sentences with registered term.
formatSetDefault()  : array{success: bool}
Format response for setting a language as default/current.
formatSimilarTerms()  : array{similar_terms: string}
Format response for similar terms.
formatUpdate()  : array{success: bool, reparsed?: int, error?: string, message?: string}
Format response for updating a language.
getPhoneticReading()  : array{phonetic_reading: string}
Get the phonetic reading of a word based on its language.
getReadingConfiguration()  : array{name: string, voiceapi: string, word_parsing: string, abbreviation: mixed, reading_mode: string, piper_voice_id?: string}
Get the reading configuration for a language.
getSentencesWithTerm()  : array<string|int, mixed>
Get sentences containing a word.
getSimilarTerms()  : array{similar_terms: string}
Get terms similar to a given term.
routeDelete()  : JsonResponse
Handle a DELETE request for this resource.
routeGet()  : JsonResponse
Handle a GET request for this resource.
routePost()  : JsonResponse
Handle a POST request for this resource.
routePut()  : JsonResponse
Handle a PUT request for this resource.
frag()  : string
Extract a fragment from the fragments array.

Properties

Methods

formatCreate()

Format response for creating a new language.

public formatCreate(array<string, mixed> $data) : array{success: bool, id?: int, error?: string}
Parameters
$data : array<string, mixed>

Language data from request

Return values
array{success: bool, id?: int, error?: string}

formatDelete()

Format response for deleting a language.

public formatDelete(int $id) : array{success: bool, error?: string, relatedData?: array{texts: int, archivedTexts: int, words: int, feeds: int}}
Parameters
$id : int

Language ID

Return values
array{success: bool, error?: string, relatedData?: array{texts: int, archivedTexts: int, words: int, feeds: int}}

formatGetAll()

Format response for getting all languages with stats.

public formatGetAll() : array{languages: array, currentLanguageId: int}
Return values
array{languages: array, currentLanguageId: int}

formatGetDefinitions()

Format response for getting all language definitions (presets).

public formatGetDefinitions() : array{definitions: array}
Return values
array{definitions: array}

formatGetOne()

Format response for getting a single language.

public formatGetOne(int $id) : array<string|int, mixed>|null
Parameters
$id : int

Language ID

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

Language data or null if not found

formatGetStats()

Format response for getting language stats.

public formatGetStats(int $id) : array{texts: int, archivedTexts: int, words: int, feeds: int}
Parameters
$id : int

Language ID

Return values
array{texts: int, archivedTexts: int, words: int, feeds: int}

formatLanguagesWithArchivedTexts()

Format response for languages with archived text counts.

public formatLanguagesWithArchivedTexts() : array{languages: array}

Returns languages that have at least one archived text, for grouped archived texts page.

Return values
array{languages: array}

formatLanguagesWithTexts()

Format response for languages with text counts.

public formatLanguagesWithTexts() : array{languages: array}

Returns languages that have at least one text, for grouped texts page.

Return values
array{languages: array}

formatPhoneticReading()

Format response for phonetic reading.

public formatPhoneticReading(array{text?: string, language_id?: int|string, lang?: string} $params) : array{phonetic_reading: string}
Parameters
$params : array{text?: string, language_id?: int|string, lang?: string}

Request parameters

Return values
array{phonetic_reading: string}

formatReadingConfiguration()

Format response for reading configuration.

public formatReadingConfiguration(int $langId) : array<string|int, mixed|string>
Parameters
$langId : int

Language ID

Tags
psalm-return

array{name: string, voiceapi: string, word_parsing: string, abbreviation: mixed, reading_mode: string, piper_voice_id?: string}

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

formatRefresh()

Format response for refreshing (reparsing) a language's texts.

public formatRefresh(int $id) : array{success: bool, sentencesDeleted?: int, textItemsDeleted?: int, sentencesAdded?: int, textItemsAdded?: int}
Parameters
$id : int

Language ID

Return values
array{success: bool, sentencesDeleted?: int, textItemsDeleted?: int, sentencesAdded?: int, textItemsAdded?: int}

formatSentencesWithNewTerm()

Format response for sentences with new term.

public formatSentencesWithNewTerm(int $langId, string $wordLc[, bool $advancedSearch = false ]) : array<string|int, mixed>
Parameters
$langId : int

Language ID

$wordLc : string

Word in lowercase

$advancedSearch : bool = false

Whether to use advanced search

Return values
array<string|int, mixed>

Sentences with the word

formatSentencesWithRegisteredTerm()

Format response for sentences with registered term.

public formatSentencesWithRegisteredTerm(int $langId, string $wordLc, int $wordId) : array<string|int, mixed>
Parameters
$langId : int

Language ID

$wordLc : string

Word in lowercase

$wordId : int

Word ID

Return values
array<string|int, mixed>

Sentences with the word

formatSetDefault()

Format response for setting a language as default/current.

public formatSetDefault(int $id) : array{success: bool}
Parameters
$id : int

Language ID

Return values
array{success: bool}

formatSimilarTerms()

Format response for similar terms.

public formatSimilarTerms(int $langId, string $term) : array{similar_terms: string}
Parameters
$langId : int

Language ID

$term : string

Term text

Return values
array{similar_terms: string}

formatUpdate()

Format response for updating a language.

public formatUpdate(int $id, array<string, mixed> $data) : array{success: bool, reparsed?: int, error?: string, message?: string}
Parameters
$id : int

Language ID

$data : array<string, mixed>

Language data from request

Return values
array{success: bool, reparsed?: int, error?: string, message?: string}

getPhoneticReading()

Get the phonetic reading of a word based on its language.

public getPhoneticReading(string $text[, int|null $langId = null ][, string|null $langCode = null ]) : array{phonetic_reading: string}
Parameters
$text : string

Text to get phonetic reading for

$langId : int|null = null

Language ID (optional, use lang code if null)

$langCode : string|null = null

Short language name (optional)

Return values
array{phonetic_reading: string}

getReadingConfiguration()

Get the reading configuration for a language.

public getReadingConfiguration(int $langId) : array{name: string, voiceapi: string, word_parsing: string, abbreviation: mixed, reading_mode: string, piper_voice_id?: string}
Parameters
$langId : int

Language ID

Return values
array{name: string, voiceapi: string, word_parsing: string, abbreviation: mixed, reading_mode: string, piper_voice_id?: string}

getSentencesWithTerm()

Get sentences containing a word.

public getSentencesWithTerm(int $langId, string $wordLc, int|null $wordId) : array<string|int, mixed>
Parameters
$langId : int

Language ID

$wordLc : string

Word in lowercase

$wordId : int|null

Word ID (null for new terms, -1 for advanced search)

Return values
array<string|int, mixed>

Sentences with the word

getSimilarTerms()

Get terms similar to a given term.

public getSimilarTerms(int $langId, string $term) : array{similar_terms: string}
Parameters
$langId : int

Language ID

$term : string

Term to find similar terms for

Return values
array{similar_terms: string}

routeDelete()

Handle a DELETE request for this resource.

public routeDelete(array<string|int, mixed> $fragments, array<string|int, mixed> $params) : JsonResponse
Parameters
$fragments : array<string|int, mixed>

URL path segments (resource name already consumed)

$params : array<string|int, mixed>

Query/body parameters

Return values
JsonResponse

routeGet()

Handle a GET request for this resource.

public routeGet(array<string|int, mixed> $fragments, array<string|int, mixed> $params) : JsonResponse
Parameters
$fragments : array<string|int, mixed>

URL path segments (resource name already consumed)

$params : array<string|int, mixed>

Query parameters

Return values
JsonResponse

routePost()

Handle a POST request for this resource.

public routePost(array<string|int, mixed> $fragments, array<string|int, mixed> $params) : JsonResponse
Parameters
$fragments : array<string|int, mixed>

URL path segments (resource name already consumed)

$params : array<string|int, mixed>

POST/JSON body parameters

Return values
JsonResponse

routePut()

Handle a PUT request for this resource.

public routePut(array<string|int, mixed> $fragments, array<string|int, mixed> $params) : JsonResponse
Parameters
$fragments : array<string|int, mixed>

URL path segments (resource name already consumed)

$params : array<string|int, mixed>

JSON body parameters

Return values
JsonResponse

frag()

Extract a fragment from the fragments array.

protected frag(array<int, string> $fragments, int $index) : string
Parameters
$fragments : array<int, string>

The URL path fragments

$index : int

The index to extract

Return values
string

The fragment at the index, or empty string if not present


        
On this page

Search results