Skip to content

refactor: footer handler decoupling - #5991

Merged
vitormattos merged 10 commits into
mainfrom
refactor/footer-handler-decoupling
Dec 4, 2025
Merged

vitormattos merged 10 commits into
mainfrom
refactor/footer-handler-decoupling

Conversation

@vitormattos

Copy link
Copy Markdown
Member

No description provided.

@vitormattos vitormattos added this to the Next Major (33) milestone Dec 4, 2025
@vitormattos vitormattos self-assigned this Dec 4, 2025
@github-project-automation github-project-automation Bot moved this to 0. Needs triage in LibreSign Roadmap Dec 4, 2025
Breaking changes:
- getFooter() now accepts only array $dimensions parameter
- UUID must be set via setTemplateVar('uuid', $uuid) before calling getFooter()

Changes:
- Remove FileEntity dependency from getFooter() signature
- Allow customization of all template variables via setTemplateVar()
- Only fetch default values from appConfig if not already customized
- Check if 'uuid' exists in templateVars before building validationSite

Benefits:
- Reduced coupling - no dependency on FileEntity
- More flexible - all variables customizable via same API
- Cleaner design - consistent use of setTemplateVar() for all variables
- Easier testing - no need to mock FileEntity

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
- Use setTemplateVar('uuid') to pass UUID to FooterHandler
- Call getFooter() with only dimensions parameter
- Maintains all existing functionality

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
- Use setTemplateVar('uuid') before calling getFooter()
- Remove FileEntity mock creation
- Simplify test setup

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Only generate QR code if validationSite is available in templateVars.
This prevents undefined array key error when uuid is not set.

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Add tests for specific edge cases:
- testGetFooterWithoutUuid: ensures no error when uuid is not set
- testCustomValidationSiteNotOverwritten: validates that custom
  validationSite set via setTemplateVar() is not overwritten by
  appConfig defaults

These tests complement the existing dataProvider tests and ensure
the refactored code handles edge cases properly.

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Introduces a type-safe collection class for footer template variables
using magic methods (__call) with runtime type validation.

Benefits:
- Whitelist of allowed variables with expected types
- Runtime type checking for all setters
- Fluent interface for method chaining
- Clean API with only ~70 lines of code
- Prevents invalid variables or type mismatches

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Replace raw array with TemplateVariables class for better type safety
and explicit contract of available template variables.

Changes:
- Use TemplateVariables instance instead of array
- Replace array access with typed getters/setters
- Maintain backward compatibility via setTemplateVar()
- Improved code readability with explicit method names

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Add 21 tests with 53 assertions covering:
- Setters/getters for all 9 variables (via DataProvider)
- Null returns for unset variables
- Array conversion and merge functionality
- Whitelist validation (rejects unknown variables)
- Type validation (rejects wrong types)
- Invalid method calls

Use PHP 8 attributes for DataProviders for cleaner syntax.

Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
@vitormattos
vitormattos force-pushed the refactor/footer-handler-decoupling branch from 8fa149e to 6c27ee1 Compare December 4, 2025 16:50
@vitormattos

Copy link
Copy Markdown
Member Author

/backport to stable32

@vitormattos

Copy link
Copy Markdown
Member Author

/backport to stable31

@backportbot-libresign backportbot-libresign Bot added the backport-request Request to backport a change to supported stable branches label Dec 4, 2025
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
@vitormattos
vitormattos merged commit 6f73d6b into main Dec 4, 2025
30 checks passed
@vitormattos
vitormattos deleted the refactor/footer-handler-decoupling branch December 4, 2025 16:58
@github-project-automation github-project-automation Bot moved this from 0. Needs triage to 4. to release in LibreSign Roadmap Dec 4, 2025
@backportbot-libresign backportbot-libresign Bot removed the backport-request Request to backport a change to supported stable branches label Dec 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

1 participant