DictionaryFacade
in package
Facade for the Dictionary module.
Provides a simplified interface for dictionary operations, wrapping the underlying LocalDictionaryService.
Tags
Table of Contents
Properties
Methods
- __construct() : mixed
- Create a new DictionaryFacade.
- addEntriesBatch() : int
- Add entries to a dictionary in batch.
- create() : int
- Create a new dictionary.
- delete() : bool
- Delete a dictionary.
- getAllForLanguage() : array<string|int, LocalDictionary>
- Get all dictionaries for a language.
- getById() : LocalDictionary|null
- Get a dictionary by ID.
- getEntries() : array{entries: array, total: int, page: int, perPage: int}
- Get entries for a dictionary (paginated).
- getForLanguage() : array<string|int, LocalDictionary>
- Get enabled dictionaries for a language.
- getImporter() : ImporterInterface
- Get the appropriate importer for a format.
- getLocalDictMode() : int
- Get the local dictionary mode for a language.
- hasLocalDictionaries() : bool
- Check if a language has any local dictionaries.
- lookup() : array<string|int, array{term: string, definition: string, reading: ?string, pos: ?string, dictionary: string}>
- Look up a term in local dictionaries.
- lookupPrefix() : array<string|int, array{term: string, definition: string}>
- Look up a term with prefix matching.
- update() : bool
- Update a dictionary.
Properties
$dictionaryService
private
LocalDictionaryService
$dictionaryService
Methods
__construct()
Create a new DictionaryFacade.
public
__construct(LocalDictionaryService $dictionaryService) : mixed
Parameters
- $dictionaryService : LocalDictionaryService
-
The dictionary service
addEntriesBatch()
Add entries to a dictionary in batch.
public
addEntriesBatch(int $dictId, iterable<string|int, array{term: string, definition: string, reading?: ?string, pos?: ?string}> $entries) : int
Parameters
- $dictId : int
-
Dictionary ID
- $entries : iterable<string|int, array{term: string, definition: string, reading?: ?string, pos?: ?string}>
-
Entries to add
Return values
int —Number of entries added
create()
Create a new dictionary.
public
create(int $languageId, string $name[, string $sourceFormat = 'csv' ][, string|null $description = null ]) : int
Parameters
- $languageId : int
-
Language ID
- $name : string
-
Dictionary name
- $sourceFormat : string = 'csv'
-
Source format (csv, json, stardict)
- $description : string|null = null
-
Optional description
Return values
int —The new dictionary ID
delete()
Delete a dictionary.
public
delete(int $dictId) : bool
Parameters
- $dictId : int
-
Dictionary ID
Return values
bool —Success
getAllForLanguage()
Get all dictionaries for a language.
public
getAllForLanguage(int $languageId) : array<string|int, LocalDictionary>
Parameters
- $languageId : int
-
Language ID
Return values
array<string|int, LocalDictionary>getById()
Get a dictionary by ID.
public
getById(int $dictId) : LocalDictionary|null
Parameters
- $dictId : int
-
Dictionary ID
Return values
LocalDictionary|nullgetEntries()
Get entries for a dictionary (paginated).
public
getEntries(int $dictId[, int $page = 1 ][, int $perPage = 50 ]) : array{entries: array, total: int, page: int, perPage: int}
Parameters
- $dictId : int
-
Dictionary ID
- $page : int = 1
-
Page number (1-based)
- $perPage : int = 50
-
Entries per page
Return values
array{entries: array, total: int, page: int, perPage: int}getForLanguage()
Get enabled dictionaries for a language.
public
getForLanguage(int $languageId) : array<string|int, LocalDictionary>
Parameters
- $languageId : int
-
Language ID
Return values
array<string|int, LocalDictionary>getImporter()
Get the appropriate importer for a format.
public
getImporter(string $format[, string $originalName = '' ]) : ImporterInterface
Parameters
- $format : string
-
Import format (csv, json, stardict)
- $originalName : string = ''
-
Original filename for auto-detection
Tags
Return values
ImporterInterfacegetLocalDictMode()
Get the local dictionary mode for a language.
public
getLocalDictMode(int $languageId) : int
Parameters
- $languageId : int
-
Language ID
Return values
int —Mode (0=online only, 1=local first, 2=local only, 3=combined)
hasLocalDictionaries()
Check if a language has any local dictionaries.
public
hasLocalDictionaries(int $languageId) : bool
Parameters
- $languageId : int
-
Language ID
Return values
boollookup()
Look up a term in local dictionaries.
public
lookup(int $languageId, string $term) : array<string|int, array{term: string, definition: string, reading: ?string, pos: ?string, dictionary: string}>
Parameters
- $languageId : int
-
Language ID
- $term : string
-
Term to look up
Return values
array<string|int, array{term: string, definition: string, reading: ?string, pos: ?string, dictionary: string}>lookupPrefix()
Look up a term with prefix matching.
public
lookupPrefix(int $languageId, string $prefix[, int $limit = 10 ]) : array<string|int, array{term: string, definition: string}>
Parameters
- $languageId : int
-
Language ID
- $prefix : string
-
Term prefix
- $limit : int = 10
-
Maximum results
Return values
array<string|int, array{term: string, definition: string}>update()
Update a dictionary.
public
update(LocalDictionary $dictionary) : bool
Parameters
- $dictionary : LocalDictionary
-
Dictionary entity
Return values
bool —Success