MySqlLanguageRepository
in package
implements
LanguageRepositoryInterface
MySQL implementation of LanguageRepositoryInterface.
Provides database access for language management operations.
Tags
Table of Contents
Interfaces
- LanguageRepositoryInterface
- Repository interface for Language entity.
Properties
- $columnMap : array<string, string>
- $primaryKey : string
- $tableName : string
Methods
- createEmpty() : Language
- Create a new empty language entity with default values.
- delete() : void
- Delete a language by ID.
- exists() : bool
- Check if a language exists.
- find() : Language|null
- Find a language by its ID.
- findAllActive() : array<string|int, Language>
- Find all non-empty languages (those with a name).
- findByName() : Language|null
- Find a language by name.
- findEmptyLanguageId() : int|null
- Find the first empty language record (for reuse on insert).
- getAllAsDict() : array<string, int>
- Get languages as name => id dictionary.
- getForSelect() : array<int, array{id: int, name: string}>
- Get languages formatted for select dropdown options.
- getName() : string|null
- Get the name of a language by ID.
- getTranslatorUri() : string|null
- Get the translator URI for a language.
- getWordCharacters() : string|null
- Get the word character regex for a language.
- isRightToLeft() : bool
- Check if a language is RTL (right-to-left).
- nameExists() : bool
- Check if a language name exists.
- save() : void
- Save a language entity (create or update).
- mapToEntity() : Language
- Map a database row to a Language entity.
- mapToRow() : array<string, scalar|null>
- Map a Language entity to database row.
- query() : QueryBuilder
- Get a query builder for this repository's table.
Properties
$columnMap
private
array<string, string>
$columnMap
= ['id' => 'LgID', 'name' => 'LgName', 'dict1uri' => 'LgDict1URI', 'dict2uri' => 'LgDict2URI', 'translator' => 'LgGoogleTranslateURI', 'dict1popup' => 'LgDict1PopUp', 'dict2popup' => 'LgDict2PopUp', 'translatorpopup' => 'LgGoogleTranslatePopUp', 'sourcelang' => 'LgSourceLang', 'targetlang' => 'LgTargetLang', 'exporttemplate' => 'LgExportTemplate', 'textsize' => 'LgTextSize', 'charactersubst' => 'LgCharacterSubstitutions', 'regexpsplitsent' => 'LgRegexpSplitSentences', 'exceptionsplitsent' => 'LgExceptionsSplitSentences', 'regexpwordchar' => 'LgRegexpWordCharacters', 'parsertype' => 'LgParserType', 'removespaces' => 'LgRemoveSpaces', 'spliteachchar' => 'LgSplitEachChar', 'rightoleft' => 'LgRightToLeft', 'ttsvoiceapi' => 'LgTTSVoiceAPI', 'showromanization' => 'LgShowRomanization', 'localdictmode' => 'LgLocalDictMode']
Property to column mapping
$primaryKey
private
string
$primaryKey
= 'LgID'
Primary key column
$tableName
private
string
$tableName
= 'languages'
Table name without prefix
Methods
createEmpty()
Create a new empty language entity with default values.
public
createEmpty() : Language
Return values
Languagedelete()
Delete a language by ID.
public
delete(int $id) : void
Parameters
- $id : int
-
Language ID
exists()
Check if a language exists.
public
exists(int $id) : bool
Parameters
- $id : int
-
Language ID
Return values
boolfind()
Find a language by its ID.
public
find(int $id) : Language|null
Parameters
- $id : int
-
Language ID
Return values
Language|null —Language entity or null if not found
findAllActive()
Find all non-empty languages (those with a name).
public
findAllActive([string $orderBy = 'LgName' ][, string $direction = 'ASC' ]) : array<string|int, Language>
Parameters
- $orderBy : string = 'LgName'
-
Column to order by (default: name)
- $direction : string = 'ASC'
-
Sort direction (default: ASC)
Return values
array<string|int, Language>findByName()
Find a language by name.
public
findByName(string $name) : Language|null
Parameters
- $name : string
-
Language name
Return values
Language|nullfindEmptyLanguageId()
Find the first empty language record (for reuse on insert).
public
findEmptyLanguageId() : int|null
Return values
int|null —The empty language ID or null
getAllAsDict()
Get languages as name => id dictionary.
public
getAllAsDict() : array<string, int>
Return values
array<string, int>getForSelect()
Get languages formatted for select dropdown options.
public
getForSelect([int $maxNameLength = 30 ]) : array<int, array{id: int, name: string}>
Parameters
- $maxNameLength : int = 30
-
Maximum name length before truncation
Return values
array<int, array{id: int, name: string}>getName()
Get the name of a language by ID.
public
getName(int $id) : string|null
Parameters
- $id : int
-
Language ID
Return values
string|null —The language name or null if not found
getTranslatorUri()
Get the translator URI for a language.
public
getTranslatorUri(int $id) : string|null
Parameters
- $id : int
-
Language ID
Return values
string|null —The translator URI or null if not found
getWordCharacters()
Get the word character regex for a language.
public
getWordCharacters(int $id) : string|null
Parameters
- $id : int
-
Language ID
Return values
string|null —The regex or null if not found
isRightToLeft()
Check if a language is RTL (right-to-left).
public
isRightToLeft(int $id) : bool
Parameters
- $id : int
-
Language ID
Return values
boolnameExists()
Check if a language name exists.
public
nameExists(string $name[, int|null $excludeId = null ]) : bool
Parameters
- $name : string
-
Language name
- $excludeId : int|null = null
-
Language ID to exclude (for updates)
Return values
boolsave()
Save a language entity (create or update).
public
save(Language $entity) : void
Parameters
- $entity : Language
-
The language to save
mapToEntity()
Map a database row to a Language entity.
private
mapToEntity(array<string, mixed> $row) : Language
Parameters
- $row : array<string, mixed>
-
Database row
Return values
LanguagemapToRow()
Map a Language entity to database row.
private
mapToRow(Language $entity) : array<string, scalar|null>
Parameters
- $entity : Language
-
The language entity
Return values
array<string, scalar|null>query()
Get a query builder for this repository's table.
private
query() : QueryBuilder