@@ -528,7 +528,7 @@ There are two events: `PostExtract` and `PreHydrate`.
528528For this functionality we use the [ symfony/event-dispatcher] ( https://symfony.com/doc/current/components/event_dispatcher.html ) .
529529
530530``` php
531- use Patchlevel\Hydrator\Cryptography\PersonalDataPayloadCryptographer ;
531+ use Patchlevel\Hydrator\Cryptography\SensitiveDataPayloadCryptographer ;
532532use Patchlevel\Hydrator\Cryptography\Store\CipherKeyStore;
533533use Patchlevel\Hydrator\Metadata\Event\EventMetadataFactory;
534534use Patchlevel\Hydrator\MetadataHydrator;
@@ -557,8 +557,8 @@ $hydrator = new MetadataHydrator(eventDispatcher: $eventDispatcher);
557557
558558### Cryptography
559559
560- The library also offers the possibility to encrypt and decrypt personal data.
561- For this purpose, a key is created for each subject ID, which is used to encrypt the personal data.
560+ The library also offers the possibility to encrypt and decrypt sensitive data, e.g. personal data of customers .
561+ For this purpose, a key is created for each subject ID, which is used to encrypt the sensitive data.
562562
563563#### DataSubjectId
564564
@@ -579,42 +579,62 @@ final class EmailChanged
579579
580580> [ !WARNING]
581581> The ` DataSubjectId ` must be a string. You can use a normalizer to convert it to a string.
582- > The Subject ID cannot be personal data.
582+ > The Subject ID cannot be sensitive data.
583583
584- #### PersonalData
584+ First we need to define what the subject id is.
585585
586- Next, we need to specify which fields we want to encrypt.
586+ ``` php
587+ use Patchlevel\Hydrator\Attribute\DataSubjectId;
588+
589+ final class EmailChanged
590+ {
591+ public function __construct(
592+ #[DataSubjectId(name: 'profile')]
593+ public readonly string $profileId,
594+ ) {
595+ }
596+ }
597+ ```
598+
599+ You can also use multiple data subject id's in one event by defining the name of the subject id's.
587600
588601``` php
589602use Patchlevel\Hydrator\Attribute\DataSubjectId;
590- use Patchlevel\Hydrator\Attribute\PersonalData ;
603+ use Patchlevel\Hydrator\Attribute\SensitiveData ;
591604
592605final class DTO
593606{
594607 public function __construct(
595- #[DataSubjectId]
596- public readonly string $profileId,
597- #[PersonalData]
598- public readonly string|null $email,
608+ #[DataSubjectId(name: 'profile1')]
609+ public readonly string $profile1Id,
610+ #[SensitiveData(subjectIdName: 'profile1')]
611+ public readonly string|null $email1,
612+ #[DataSubjectId(name: 'profile2')]
613+ public readonly string $profile2Id,
614+ #[SensitiveData(subjectIdName: 'profile2')]
615+ public readonly string|null $email2,
599616 ) {
600617 }
601618}
602619```
603620
621+ > [ !NOTE]
622+ > The default name of ` DataSubjectId ` is ` default ` .
623+
604624If the information could not be decrypted, then a fallback value is inserted.
605625The default fallback value is ` null ` .
606626You can change this by setting the ` fallback ` parameter.
607627In this case ` unknown ` is added:
608628
609629``` php
610- use Patchlevel\Hydrator\Attribute\PersonalData ;
630+ use Patchlevel\Hydrator\Attribute\SensitiveData ;
611631
612632final class DTO
613633{
614634 public function __construct(
615635 #[DataSubjectId]
616636 public readonly string $profileId,
617- #[PersonalData (fallback: 'unknown')]
637+ #[SensitiveData (fallback: 'unknown')]
618638 public readonly string $name,
619639 ) {
620640 }
@@ -625,16 +645,16 @@ You can also use a callable as a fallback.
625645
626646``` php
627647use Patchlevel\Hydrator\Attribute\DataSubjectId;
628- use Patchlevel\Hydrator\Attribute\PersonalData ;
648+ use Patchlevel\Hydrator\Attribute\SensitiveData ;
629649
630650final class ProfileCreated
631651{
632652 public function __construct(
633653 #[DataSubjectId]
634654 public readonly string $profileId,
635- #[PersonalData (fallback: 'deleted profile')]
655+ #[SensitiveData (fallback: 'deleted profile')]
636656 public readonly string $name,
637- #[PersonalData (fallbackCallable: [self::class, 'anonymizedEmail'])]
657+ #[SensitiveData (fallbackCallable: [self::class, 'anonymizedEmail'])]
638658 public readonly string $email,
639659 ) {
640660 }
@@ -655,13 +675,13 @@ final class ProfileCreated
655675Here we show you how to configure the cryptography.
656676
657677``` php
658- use Patchlevel\Hydrator\Cryptography\PersonalDataPayloadCryptographer ;
678+ use Patchlevel\Hydrator\Cryptography\SensitiveDataPayloadCryptographer ;
659679use Patchlevel\Hydrator\Cryptography\Store\CipherKeyStore;
660680use Patchlevel\Hydrator\Metadata\Event\EventMetadataFactory;
661681use Patchlevel\Hydrator\MetadataHydrator;
662682
663683$cipherKeyStore = new InMemoryCipherKeyStore();
664- $cryptographer = PersonalDataPayloadCryptographer ::createWithDefaultSettings($cipherKeyStore);
684+ $cryptographer = SensitiveDataPayloadCryptographer ::createWithDefaultSettings($cipherKeyStore);
665685$hydrator = new MetadataHydrator(cryptographer: $cryptographer);
666686```
667687
0 commit comments