Repository navigation
Release v1.0.5
Release 1.0.5 - anonymizeService, truncate by discriminator, Doctrine ORM 3, UtmFaker campaign min_length, demo breadcrumb fix
Changelog
Added
-
Anonymization via custom service (
anonymizeService): Entity-level option to delegate anonymization to a service instead ofAnonymizePropertyattributes.- New parameter on
#[Anonymize]:anonymizeService(string, service id). When set, the bundle calls this service for each record instead of applying property-based anonymization. - New interface:
Nowo\AnonymizeBundle\Service\EntityAnonymizerServiceInterfacewith methodanonymize(EntityManagerInterface $em, ClassMetadata $metadata, array $record, bool $dryRun): array(returns column => value for updates). - Useful for polymorphic entities (different logic per subtype), API-based anonymization, or complex rules. Documented in USAGE.md and CONFIGURATION.md.
- Demos:
SmsNotificationusesSmsNotificationAnonymizerServicein all demo projects (symfony6, symfony7, symfony8).
- New parameter on
-
Truncate by discriminator (polymorphic entities): When an entity uses Doctrine inheritance (STI/CTI) and
truncate: true, the bundle now deletes only rows for that entity's discriminator value instead of truncating the whole table.- Detection is automatic via
inheritanceType,discriminatorColumn, anddiscriminatorValuein metadata. - No extra configuration: normal entities still get full table truncate; polymorphic entities get
DELETE FROM table WHERE discriminator_column = value. - When loading records for anonymization, the query is also restricted by discriminator so only rows of that subtype are processed.
- Detection is automatic via
Changed
- AnonymizeService: Constructor accepts optional
ContainerInterface $containerto resolveanonymizeServiceby id. Required when any entity usesanonymizeService(bundle wiring provides it when available).
Documentation
- USAGE.md: New section "Anonymizing via a custom service (anonymizeService)" with interface and example; truncation section extended with "Polymorphic entities (STI/CTI)".
- CONFIGURATION.md:
#[Anonymize]syntax updated withanonymizeServiceand polymorphic truncate behavior. - Demo folders: References updated from
demo-symfony6/7/8tosymfony6/7/8in docs and scripts where applicable.
Demo
- Notification CRUD (symfony6, 7, 8): Fixed breadcrumb route
notification_index_index→notification_indexin_breadcrumbs.html.twig(use_route,listRoute/indexRoute/routePrefix, and entityName fallback for Notifications). Notification index/show templates now passlistRoute: 'notification_index'androutePrefix: 'notification'withonlyto avoid context leakage. All three demos aligned (same breadcrumb logic and notification includes).
Fixed
- Doctrine ORM 3 compatibility:
AnonymizeService::getDiscriminatorForTruncate()now accepts both array (ORM 2.x) andDiscriminatorColumnMappingobject (ORM 3.x) fordiscriminatorColumnmetadata. Tests useDiscriminatorColumnMappingwhen available. - UtmFaker:
generateCampaign()now enforcesmin_lengthandmax_lengthin all code paths (predefined patterns and random words); previously a single short word could yield a campaign shorter thanmin_length. - AnonymizeTest:
testAnonymizePropertiesArePublicnow usesproperty_exists()instead ofisset()so nullable properties (e.g.truncate_order) are correctly reported as present.