Output Documents
Introduction
Output documents are generated by document builders that implement the interface in Klaro\QuotationBundle\Api\DocumentBuilderInterface
. Builder services are tagged with the name klaro_quotation.document_builder
. Output documents are configured under klaro_quotation.documents
as explained in the Configuration page.
In code, builders can be accessed through the klaro_quotation.output_document_manager
with the method getBuilder([type])
where type is the alias of the builder service.
By default, these builders are available:
Type | Builder | Description |
---|---|---|
file | File Passthrough | Normal file download. |
zip | Zip file archiver | Makes an archive of given documents. |
Below is the class diagram for output documents.
Default builders
File Passthrough
File passthrough is a normal file download that passes the configured source document as a downloadable document:
klaro_quotation:
documents:
datasheet: { type: file, title: Datasheet, source: ../path/../datasheet.pdf }
Zip file archiver
Zip file archiver makes a .zip archive from one or more configured output documents. Use the document keys in the source list to define list of archived documents.
klaro_quotation:
documents:
datasheet1: { type: file, title: Datasheet 1, source: ../path/../datasheet1.pdf }
datasheet2: { type: file, title: Datasheet 2, source: ../path/../datasheet2.pdf }
zipped: { type: zip, title: Datasheets (.zip), source: { items: [datasheet1, datasheet2] } }
Generating single document
The process to generate a single output document is described below.
Below are the events that can be used to hook on to the document creation process. See the class Klaro\QuotationBundle\Api\DocumentEvents
for more info.
Event | Description |
---|---|
QUOTATION_DOCUMENT_GENERATE | Triggered when the requested document is about to be generated. |
QUOTATION_DOCUMENT_READY | Triggered when the requested document has been generated and is ready to be set for the response. |
Generating multiple documents
When generate multiple documents, they generated like the single ones but the resulting file is packaged inside .zip file. If there are other .zip output documents, the files are extracted and packaged in their own folder under the main .zip file.
Below is the process for generating multiple documents.