TermCrudApiHandler
in package
Handler for term CRUD API operations.
Provides endpoints for:
- Basic CRUD operations (get, create, update, delete)
- Term details retrieval
- Quick term creation
- Full term editing with lemma, tags, notes
Tags
Table of Contents
Properties
- $contextService : WordContextService
- $discoveryService : WordDiscoveryService
- $facade : VocabularyFacade
- $findSimilarTerms : FindSimilarTerms
- $linkingService : WordLinkingService
Methods
- __construct() : mixed
- Constructor.
- createQuickTerm() : array{term_id?: int, term?: string, term_lc?: string, hex?: string, error?: string}
- Create a term quickly with wellknown (99) or ignored (98) status.
- createTerm() : array{success: bool, id?: int, textLc?: string, hex?: string, error?: string}
- Create a new term.
- createTermFull() : array{success?: bool, term?: array, error?: string}
- Create a term with full data (translation, romanization, sentence, tags, status).
- deleteTerm() : array{deleted: bool, error?: string}
- Delete a term.
- deleteTerms() : array{deleted: int, error?: string}
- Delete multiple terms.
- formatCreateTerm() : array<string|int, mixed>
- Format response for creating a term.
- formatCreateTermFull() : array<string|int, mixed>
- Format response for creating a term with full data.
- formatDeleteTerm() : array<string|int, mixed>
- Format response for deleting a term.
- formatGetTerm() : array<string|int, mixed>
- Format response for getting a term.
- formatGetTermDetails() : array<string|int, mixed>
- Format response for getting term details.
- formatGetTermForEdit() : array<string|int, mixed>
- Format response for getting term data for editing.
- formatQuickCreate() : array{term_id?: int, term?: string, term_lc?: string, hex?: string, error?: string}
- Format response for quick term creation.
- formatUpdateTerm() : array<string|int, mixed>
- Format response for updating a term.
- formatUpdateTermFull() : array<string|int, mixed>
- Format response for updating a term with full data.
- getTerm() : array<string|int, mixed>
- Get a term by ID.
- getTermDetails() : array{id: int, text: string, textLc: string, lemma: string, lemmaLc: string, translation: string, romanization: string, status: int, langId: int, sentence: string, notes: string, tags: string[], statusLabel: string}|array{error: string}
- Get detailed term information including sentence and tags.
- getTermForEdit() : array<string|int, mixed>
- Get term data prepared for editing in modal.
- updateTerm() : array{success: bool, error?: string}
- Update a term.
- updateTermFull() : array{success?: bool, term?: array, error?: string}
- Update a term with full data.
- getSimilarTermsForEdit() : array<string|int, mixed>
- Get similar terms for the edit form.
Properties
$contextService
private
WordContextService
$contextService
$discoveryService
private
WordDiscoveryService
$discoveryService
$facade
private
VocabularyFacade
$facade
$findSimilarTerms
private
FindSimilarTerms
$findSimilarTerms
$linkingService
private
WordLinkingService
$linkingService
Methods
__construct()
Constructor.
public
__construct([VocabularyFacade|null $facade = null ][, FindSimilarTerms|null $findSimilarTerms = null ][, WordContextService|null $contextService = null ][, WordDiscoveryService|null $discoveryService = null ][, WordLinkingService|null $linkingService = null ]) : mixed
Parameters
- $facade : VocabularyFacade|null = null
-
Vocabulary facade
- $findSimilarTerms : FindSimilarTerms|null = null
-
Find similar terms use case
- $contextService : WordContextService|null = null
-
Context service
- $discoveryService : WordDiscoveryService|null = null
-
Discovery service
- $linkingService : WordLinkingService|null = null
-
Linking service
createQuickTerm()
Create a term quickly with wellknown (99) or ignored (98) status.
public
createQuickTerm(int $textId, int $ord, int $status) : array{term_id?: int, term?: string, term_lc?: string, hex?: string, error?: string}
Parameters
- $textId : int
-
Text ID containing the word
- $ord : int
-
Word position (order) in text
- $status : int
-
Status to set (98 for ignored, 99 for well-known)
Return values
array{term_id?: int, term?: string, term_lc?: string, hex?: string, error?: string}createTerm()
Create a new term.
public
createTerm(array<string|int, mixed> $data) : array{success: bool, id?: int, textLc?: string, hex?: string, error?: string}
Parameters
- $data : array<string|int, mixed>
-
Term data:
- langId: int Language ID
- text: string Term text
- status: int Status (1-5, 98, 99)
- translation: string Translation
- romanization: string Romanization (optional)
- sentence: string Example sentence (optional)
Return values
array{success: bool, id?: int, textLc?: string, hex?: string, error?: string}createTermFull()
Create a term with full data (translation, romanization, sentence, tags, status).
public
createTermFull(array<string|int, mixed> $data) : array{success?: bool, term?: array, error?: string}
Parameters
- $data : array<string|int, mixed>
-
Term data:
- textId: Text ID
- position: Position in text
- translation: Translation
- romanization: Romanization (optional)
- sentence: Example sentence (optional)
- notes: Notes (optional)
- status: Status (1-5, default: 1)
- tags: Array of tag names (optional)
Return values
array{success?: bool, term?: array, error?: string}deleteTerm()
Delete a term.
public
deleteTerm(int $termId) : array{deleted: bool, error?: string}
Parameters
- $termId : int
-
Term ID
Return values
array{deleted: bool, error?: string}deleteTerms()
Delete multiple terms.
public
deleteTerms(array<string|int, int> $termIds) : array{deleted: int, error?: string}
Parameters
- $termIds : array<string|int, int>
-
Term IDs
Return values
array{deleted: int, error?: string}formatCreateTerm()
Format response for creating a term.
public
formatCreateTerm(array<string|int, mixed> $data) : array<string|int, mixed>
Parameters
- $data : array<string|int, mixed>
-
Term data
Return values
array<string|int, mixed>formatCreateTermFull()
Format response for creating a term with full data.
public
formatCreateTermFull(array<string|int, mixed> $data) : array<string|int, mixed>
Parameters
- $data : array<string|int, mixed>
-
Term data
Return values
array<string|int, mixed>formatDeleteTerm()
Format response for deleting a term.
public
formatDeleteTerm(int $termId) : array<string|int, mixed>
Parameters
- $termId : int
-
Term ID
Return values
array<string|int, mixed>formatGetTerm()
Format response for getting a term.
public
formatGetTerm(int $termId) : array<string|int, mixed>
Parameters
- $termId : int
-
Term ID
Return values
array<string|int, mixed>formatGetTermDetails()
Format response for getting term details.
public
formatGetTermDetails(int $termId[, string|null $ann = null ]) : array<string|int, mixed>
Parameters
- $termId : int
-
Term ID
- $ann : string|null = null
-
Optional annotation to highlight
Return values
array<string|int, mixed>formatGetTermForEdit()
Format response for getting term data for editing.
public
formatGetTermForEdit(int $textId, int $position[, int|null $wordId = null ]) : array<string|int, mixed>
Parameters
- $textId : int
-
Text ID
- $position : int
-
Position in text
- $wordId : int|null = null
-
Word ID
Return values
array<string|int, mixed>formatQuickCreate()
Format response for quick term creation.
public
formatQuickCreate(int $textId, int $position, int $status) : array{term_id?: int, term?: string, term_lc?: string, hex?: string, error?: string}
Parameters
- $textId : int
-
Text ID
- $position : int
-
Word position in text
- $status : int
-
Status (98 or 99)
Return values
array{term_id?: int, term?: string, term_lc?: string, hex?: string, error?: string}formatUpdateTerm()
Format response for updating a term.
public
formatUpdateTerm(int $termId, array<string|int, mixed> $data) : array<string|int, mixed>
Parameters
- $termId : int
-
Term ID
- $data : array<string|int, mixed>
-
Term data
Return values
array<string|int, mixed>formatUpdateTermFull()
Format response for updating a term with full data.
public
formatUpdateTermFull(int $termId, array<string|int, mixed> $data) : array<string|int, mixed>
Parameters
- $termId : int
-
Term ID
- $data : array<string|int, mixed>
-
Term data
Return values
array<string|int, mixed>getTerm()
Get a term by ID.
public
getTerm(int $termId) : array<string|int, mixed>
Parameters
- $termId : int
-
Term ID
Return values
array<string|int, mixed> —Term data or error
getTermDetails()
Get detailed term information including sentence and tags.
public
getTermDetails(int $termId[, string|null $ann = null ]) : array{id: int, text: string, textLc: string, lemma: string, lemmaLc: string, translation: string, romanization: string, status: int, langId: int, sentence: string, notes: string, tags: string[], statusLabel: string}|array{error: string}
Parameters
- $termId : int
-
Term ID
- $ann : string|null = null
-
Annotation to highlight in translation
Return values
array{id: int, text: string, textLc: string, lemma: string, lemmaLc: string, translation: string, romanization: string, status: int, langId: int, sentence: string, notes: string, tags: string[], statusLabel: string}|array{error: string}getTermForEdit()
Get term data prepared for editing in modal.
public
getTermForEdit(int $textId, int $position[, int|null $wordId = null ]) : array<string|int, mixed>
Parameters
- $textId : int
-
Text ID
- $position : int
-
Position in text
- $wordId : int|null = null
-
Word ID (for existing terms)
Return values
array<string|int, mixed> —Term data with language settings and similar terms
updateTerm()
Update a term.
public
updateTerm(int $termId, array<string|int, mixed> $data) : array{success: bool, error?: string}
Parameters
- $termId : int
-
Term ID
- $data : array<string|int, mixed>
-
Fields to update
Return values
array{success: bool, error?: string}updateTermFull()
Update a term with full data.
public
updateTermFull(int $termId, array<string|int, mixed> $data) : array{success?: bool, term?: array, error?: string}
Parameters
- $termId : int
-
Term ID
- $data : array<string|int, mixed>
-
Term data:
- translation: Translation
- romanization: Romanization (optional)
- sentence: Example sentence (optional)
- notes: Notes (optional)
- status: Status (1-5)
- tags: Array of tag names (optional)
Return values
array{success?: bool, term?: array, error?: string}getSimilarTermsForEdit()
Get similar terms for the edit form.
private
getSimilarTermsForEdit(int $langId, string $termLc, int|null $excludeId) : array<string|int, mixed>
Parameters
- $langId : int
-
Language ID
- $termLc : string
-
Term in lowercase
- $excludeId : int|null
-
Word ID to exclude (current term)
Return values
array<string|int, mixed> —Array of similar terms