Skip to content

✨ Add domain field to Voucher entity#1056

Open
0x46616c6b wants to merge 2 commits intomainfrom
feature/voucher-domain
Open

✨ Add domain field to Voucher entity#1056
0x46616c6b wants to merge 2 commits intomainfrom
feature/voucher-domain

Conversation

@0x46616c6b
Copy link
Member

@0x46616c6b 0x46616c6b commented Feb 14, 2026

Summary

  • Add domain field to Voucher entity via DomainAwareTrait (ManyToOne, NOT NULL), so each voucher stores which domain it is valid for. During registration, the voucher now determines the domain of the new user account.
  • Introduce VoucherManager service (src/Service/VoucherManager.php) consolidating VoucherCreator, VoucherFactory, and VoucherHandler into a single final readonly manager with create(), assertDomainPermission(), and getVouchersByUser() methods.
  • Update registration flow so RegistrationType receives the domain as a form option (from the voucher) instead of querying the default domain at construction time. The template shows the voucher's domain in the title, subtitle, and email suffix.
  • Show voucher domain on user voucher page: Each voucher (active and redeemed) now displays its associated domain as a subtext below the code. Remove the obsolete domain == user_domain guard that blocked the voucher section for users on non-default domains.
  • Add --domain CLI option to app:voucher:create command (defaults to user's own domain).
  • Update Sonata Admin (VoucherAdmin) with domain field in form, list column, and datagrid filter.
  • Add database migration that backfills existing vouchers with the default domain.
Bildschirmfoto am 2026-02-14 um 13 30 47 Bildschirmfoto am 2026-02-14 um 13 24 08

Permission model

  • ROLE_ADMIN: can create vouchers for any domain
  • All other roles: restricted to their own domain (enforced by VoucherManager::assertDomainPermission())
  • DomainFilter (Doctrine SQL filter) now auto-applies to Voucher via DomainAwareTrait

The changes and the PR were generated by OpenCode.

Vouchers now store which domain they are valid for. During registration,
the voucher determines the domain of the new user account instead of
always using the default domain.

Key changes:
- Add DomainAwareTrait to Voucher entity with NOT NULL constraint
- Introduce VoucherManager service replacing VoucherCreator, VoucherFactory
  and VoucherHandler with unified create/permission/auto-create logic
- Registration form receives domain from voucher instead of querying
  the default domain at construction time
- CLI command gains --domain option (defaults to user domain)
- VoucherAdmin updated with domain field, filter and list column
- Migration backfills existing vouchers with the default domain

Co-Authored-By: OpenCode <noreply@opencode.ai>
@0x46616c6b 0x46616c6b force-pushed the feature/voucher-domain branch from 0a0df6f to 96d888a Compare February 14, 2026 12:15
@0x46616c6b 0x46616c6b marked this pull request as ready for review February 14, 2026 12:23
Display the associated domain for each voucher (active and redeemed)
on the user-facing voucher page. Remove the obsolete domain == user_domain
guard that blocked the voucher section for users on non-default domains.

Co-Authored-By: OpenCode <noreply@opencode.ai>
@sonarqubecloud
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant