From 9979426d3825bb5335da50abde12ea4d4c88dadc Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 31 Oct 2025 14:05:20 +0000 Subject: [PATCH 1/2] Initial plan From dd4070ae56088d47c2e8abc8d3d628953b483033 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 31 Oct 2025 14:09:37 +0000 Subject: [PATCH 2/2] Fix incorrect service registration example for ExampleDocumentRenderer Co-authored-by: Isengo1989 <8600299+Isengo1989@users.noreply.github.com> --- .../document/add-custom-document-type.md | 32 +++++++++++++++---- 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/guides/plugins/plugins/checkout/document/add-custom-document-type.md b/guides/plugins/plugins/checkout/document/add-custom-document-type.md index c8d49c6b7..09960dfd6 100644 --- a/guides/plugins/plugins/checkout/document/add-custom-document-type.md +++ b/guides/plugins/plugins/checkout/document/add-custom-document-type.md @@ -341,15 +341,35 @@ Here's what the function does: Depending on the file type we either get the content with `$this->fileRendererRegistry->render()` or we need to create the content on our own. `DocumentFileRendererRegistry` acts as a central registry for document file renderers based on file extensions (e.g., .pdf, .html). It delegates the rendering of documents to the appropriate renderer implementation. -Therefore, for each registered service that extends the `AbstractDocumentTypeRenderer`, the content of the document can be generated. New types of `AbstractDocumentTypeRenderer` services can be added with `document_type.renderer` as the tag name and the file extension as a key. -```xml - - ... - - +### Registering the renderer in the service container + +Now we need to register our custom `ExampleDocumentRenderer` in the service container. Create or update your `services.xml` file: + +::: code-group + +```xml [PLUGIN_ROOT/src/Resources/config/services.xml] + + + + + + + + + + + + + ``` +::: + +Note that we're using the tag `document.renderer` to register our custom document renderer. The tag name matches what was mentioned earlier - your renderer has to be registered using the tag `document.renderer`. + ### Adding a document type template Let's have a quick look at an example document type template. Go ahead and create a new file at the path `/src/Resources/views/documents/example_document.html.twig`.