Documentation

WordCrudService

Service for basic CRUD operations on words/terms.

Handles:

  • Create, update, delete operations
  • Find by ID or text
  • Get word data and details
  • Inline edit operations
Tags
since
3.0.0

Table of Contents

Properties

$repository  : MySqlTermRepository

Methods

__construct()  : mixed
Constructor.
create()  : array{id: int, message: string, success: bool, textlc: string, text: string}
Create a new word/term.
delete()  : void
Delete a word by ID.
findById()  : array<string|int, mixed>|null
Find a word by ID.
findByText()  : int|null
Find a word by text and language.
getWordCount()  : int
Get word count for a term.
getWordData()  : array{text: string, translation: string, romanization: string}|null
Get word data including translation and romanization.
getWordDetails()  : array<string|int, mixed>|null
Get full word details for display.
getWordText()  : string|null
Get a single word's text by ID.
update()  : array{id: int, message: string, success: bool, textlc: string, text: string}
Update an existing word/term.
updateRomanization()  : string
Update romanization for a word (inline edit).
updateTranslation()  : string
Update translation for a word (inline edit).
normalizeTranslation()  : string
Normalize translation value.
termEntityToArray()  : array<string|int, mixed>
Convert a Term entity to an array format for backward compatibility.

Properties

Methods

create()

Create a new word/term.

public create(array<string|int, mixed> $data) : array{id: int, message: string, success: bool, textlc: string, text: string}
Parameters
$data : array<string|int, mixed>

Word data with keys:

  • WoLgID: Language ID
  • WoText: Term text
  • WoStatus: Learning status (1-5)
  • WoTranslation: Translation text
  • WoSentence: Example sentence
  • WoNotes: Personal notes
  • WoRomanization: Romanization/phonetic
  • WoLemma: Lemma/base form (optional)
Return values
array{id: int, message: string, success: bool, textlc: string, text: string}

delete()

Delete a word by ID.

public delete(int $wordId) : void
Parameters
$wordId : int

Word ID to delete

findById()

Find a word by ID.

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

Word ID

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

Word data or null if not found

findByText()

Find a word by text and language.

public findByText(string $textlc, int $langId) : int|null
Parameters
$textlc : string

Lowercase text

$langId : int

Language ID

Return values
int|null

Word ID or null if not found

getWordCount()

Get word count for a term.

public getWordCount(int $wordId) : int
Parameters
$wordId : int

Word ID

Return values
int

Word count

getWordData()

Get word data including translation and romanization.

public getWordData(int $wordId) : array{text: string, translation: string, romanization: string}|null
Parameters
$wordId : int

Word ID

Return values
array{text: string, translation: string, romanization: string}|null

getWordDetails()

Get full word details for display.

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

Word ID

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

Word details or null if not found

getWordText()

Get a single word's text by ID.

public getWordText(int $wordId) : string|null
Parameters
$wordId : int

Word ID

Return values
string|null

Word text or null if not found

update()

Update an existing word/term.

public update(int $wordId, array<string|int, mixed> $data) : array{id: int, message: string, success: bool, textlc: string, text: string}
Parameters
$wordId : int

Word ID

$data : array<string|int, mixed>

Word data (same keys as create())

Return values
array{id: int, message: string, success: bool, textlc: string, text: string}

updateRomanization()

Update romanization for a word (inline edit).

public updateRomanization(int $wordId, string $value) : string
Parameters
$wordId : int

Word ID

$value : string

New romanization value

Return values
string

Updated romanization value (returns '*' if empty for display)

updateTranslation()

Update translation for a word (inline edit).

public updateTranslation(int $wordId, string $value) : string
Parameters
$wordId : int

Word ID

$value : string

New translation value

Return values
string

Updated translation value

normalizeTranslation()

Normalize translation value.

private normalizeTranslation(string $translation) : string
Parameters
$translation : string

Raw translation

Return values
string

Normalized translation (empty becomes '*')

termEntityToArray()

Convert a Term entity to an array format for backward compatibility.

private termEntityToArray(Term $term) : array<string|int, mixed>
Parameters
$term : Term

Term entity

Return values
array<string|int, mixed>

Term data as associative array


        
On this page

Search results