Field types are discovered recursively from the folders configured under fields.discovery.paths in config/document-generator.php. Each entry must provide a PSR-4 namespace and its matching folder path; discovered classes must be autoloadable and extend ByTIC\DocumentGenerator\LetterFieldsTypes\Types\AbstractType.
'fields' => [
'discovery' => [
'paths' => [
'custom' => [
'namespace' => 'App\\DocumentFields\\Types',
'path' => '/path/to/app/DocumentFields/Types',
],
],
],
],Types may return one or more merge tags from providesTags(). A field record stores the merge tag and resolves it to its discovered type when getType() is called.
The reusable admin parent panel is available at resources/views/admin/letter_parents/modules/panels/item-letter.php. Add ByTIC\DocumentGenerator\Bundle\Admin\Controllers\LetterParentControllerTrait to a parent admin controller to register the admin views and expose prepareLetterParentView($item). Call this method from the controller's existing view() action with the parent record to add item, its existing letter (or null), and the upload context to the view payload, without replacing the controller's view logic.
When no letter exists, the panel reuses resources/views/admin/letter_letters/modules/item/upload.php to render the multipart upload form. It submits the letter file in the letter field and the parent's morph name and ID in the type and id_item fields expected by the existing upload action; the parent panel does not render this form when there is no parent record. An optional $this->lettersManager may be provided to supply labels, messages, and the upload URL.
The frontend letter controller trait provides a download() action before generate() is called. Add a route for both actions and link users to download; when reCAPTCHA is disabled, the page uses a three-second countdown before starting generation in a hidden frame and returns to the recipient's canonical URL. When reCAPTCHA is enabled, users must complete the widget and submit its response before generation.
The generation URL preserves the current query parameters and updates type and id_item from the resolved recipient. Override getGenerationUrl(), getLetterRecipientQuery(), or getRecipientReturnUrl() in the consuming controller when an application uses custom routes or recipient identifiers. The shared template is DocumentGenerator/letter_downloads/download; override getDownloadViewPath() or the downloadHtmlResponse() response method to customize the page.
English and Romanian package catalogs are registered from resources/lang by DocumentGeneratorProvider. Translation files are split by controller root: letters.php, letter-fields.php, and letter-downloads.php; each file keeps its full root-prefixed translation keys.
reCAPTCHA protection for letter downloads is disabled by default. Enable it in the application configuration with document-generator.recaptcha.enabled (or set 'recaptcha' => ['enabled' => true] in config/document-generator.php); when enabled, users must complete the widget before the letter is generated. The Google integration is provided by bytic/google-recaptcha, which this package declares as a development dependency. Applications that enable reCAPTCHA in production must also install it with composer require bytic/google-recaptcha and configure GOOGLE_RECAPTCHA_SITE_KEY and GOOGLE_RECAPTCHA_SECRET_KEY; a missing verifier or unsuccessful response blocks generation.
PDF generation and import use TCPDF 7 and tc-lib-pdf 8. Generate the required font data after installing dependencies by running php vendor/tecnickcom/tc-lib-pdf-font/util/build_fonts.php in the consuming application.