Kh/dev/brand aware templates - #21
Conversation
f90fbc2 to
5e6970e
Compare
There was a problem hiding this comment.
Pull request overview
Adds brand-aware email templates and assets by introducing a BrandResolver that selects template fragments/images based on the ncw.brand system config, with fallback to the default ionos brand.
Changes:
- Introduces
BrandResolverto resolve brand-specific template paths and image names with sanitization and fallback. - Updates
EMailTemplateto load templates and generate asset URLs usingBrandResolver. - Adds IONOS-branded template fragments and image assets, plus unit tests covering brand resolution and updated template behavior.
Reviewed changes
Copilot reviewed 6 out of 22 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
lib/BrandResolver.php |
New resolver for brand selection + fallback for templates and images. |
lib/EMailTemplate.php |
Uses BrandResolver for template loading and asset URL generation. |
lib/templates/email/head.html |
Legacy template file modified (currently contains placeholder content). |
lib/templates/email/ionos/head.html |
Adds brand-scoped head fragment. |
lib/templates/email/ionos/header.html |
Adds brand-scoped header fragment. |
lib/templates/email/ionos/heading.html |
Adds brand-scoped heading fragment. |
lib/templates/email/ionos/bodyBegin.html |
Adds brand-scoped bodyBegin fragment. |
lib/templates/email/ionos/bodyText.html |
Adds brand-scoped bodyText fragment. |
lib/templates/email/ionos/listBegin.html |
Adds brand-scoped listBegin fragment. |
lib/templates/email/ionos/listItem.html |
Adds brand-scoped listItem fragment. |
lib/templates/email/ionos/listEnd.html |
Adds brand-scoped listEnd fragment. |
lib/templates/email/ionos/buttonGroup.html |
Adds brand-scoped buttonGroup fragment. |
lib/templates/email/ionos/button.html |
Adds brand-scoped button fragment. |
lib/templates/email/ionos/bodyEnd.html |
Adds brand-scoped bodyEnd fragment. |
lib/templates/email/ionos/footer.html |
Adds brand-scoped footer fragment. |
lib/templates/email/ionos/tail.html |
Adds brand-scoped tail fragment. |
img/ionos/spacer.png |
Adds default brand spacer image. |
img/ionos/logo.png |
Adds default brand logo image. |
img/ionos/email.png |
Adds default brand email icon image. |
img/ionos/list-item-icon.png |
Adds default brand list item icon image. |
tests/unit/BrandResolverTest.php |
New unit tests for brand sanitization and per-file fallback behavior. |
tests/lib/EMailTemplateTest.php |
Updates tests for new brand-scoped template/image paths. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| $originalContent = file_exists($templateFile) ? file_get_contents($templateFile) : null; | ||
| $expectedContent = '<div>Test Head Template</div>'; | ||
| file_put_contents($templateFile, $expectedContent); | ||
|
|
There was a problem hiding this comment.
This test mutates a tracked template file via file_put_contents(), but the restoration logic is not protected by try/finally. If an assertion fails or an exception occurs before cleanup, the file remains modified and can break other tests; wrap the write/assertions in a try/finally (or use a temp copy) to guarantee restoration.
|
@copilot open a new pull request to apply changes based on the comments in this thread |
|
@printminion-co I've opened a new pull request, #22, to work on those changes. Once the pull request is ready, I'll request review from you. |
…olution Signed-off-by: Kai Henseler <kai.henseler@strato.de>
Add ionoscloud brand assets for NSW-689: - img/ionoscloud/logo.png: IONOS Cloud white logo (for dark blue header) - ionoscloud/header.html: logo alt/title updated to "IONOS Cloud Logo" - ionoscloud/bodyEnd.html: greeting signature changed from "IONOS SE" to "IONOS Cloud" - ionoscloud/footer.html: address block changed from "IONOS SE" to "IONOS Cloud" All other templates and images fall back to the ionos brand via BrandResolver. Activate with system config: 'ncw.brand' => 'ionoscloud'
58d1dd3 to
911878c
Compare
No description provided.