ApkgExportService
in package
Orchestrates building an .apkg from one LWT language's terms.
Pulls the terms via the term repository, looks up tags through TermTagService, runs them through ApkgTermMapper, then hands the resulting notes to ApkgWriter. The writer is the only piece that knows the Anki binary layout; this service is just data assembly.
Table of Contents
Properties
Methods
- __construct() : mixed
- default() : self
- exportLanguage() : ExportResult
- Export every term in a language. Convenience wrapper around exportTerms().
- exportTerms() : ExportResult
- Export a language's terms, optionally restricted to a specific subset.
Properties
$languages read-only
private
LanguageRepositoryInterface
$languages
$terms read-only
private
TermRepositoryInterface
$terms
$writer read-only
private
ApkgWriter
$writer
Methods
__construct()
public
__construct(TermRepositoryInterface $terms, LanguageRepositoryInterface $languages, ApkgWriter $writer) : mixed
Parameters
- $terms : TermRepositoryInterface
- $languages : LanguageRepositoryInterface
- $writer : ApkgWriter
default()
public
static default() : self
Return values
selfexportLanguage()
Export every term in a language. Convenience wrapper around exportTerms().
public
exportLanguage(int $languageId, string $outputPath) : ExportResult
Parameters
- $languageId : int
- $outputPath : string
Return values
ExportResultexportTerms()
Export a language's terms, optionally restricted to a specific subset.
public
exportTerms(int $languageId, array<int, int>|null $termIds, string $outputPath) : ExportResult
Subset semantics: any IDs not belonging to $languageId are silently skipped, so a stale browser-side selection won't leak terms across languages. Re-importing a subset .apkg only updates the terms whose guids it contains; LWT terms outside the subset are untouched, which matches what users want when they only studied a slice in Anki.
Parameters
- $languageId : int
- $termIds : array<int, int>|null
-
Subset to include; null = whole language
- $outputPath : string