1- # Personal Data (GDPR)
1+ # Sensitive Data
22
33According to GDPR, personal data must be able to be deleted upon request.
44But here we have the problem that our events are immutable and we cannot easily manipulate the event store.
@@ -42,48 +42,47 @@ final class EmailChanged
4242
4343::: tip
4444You can use the ` DataSubjectId ` in aggregates for snapshots too.
45- :::
46-
47- ### PersonalData
45+ :::
46+ ### SensitiveData
4847
49- Next, you have to mark the properties that should be encrypted with the ` #[PersonalData ] ` attribute.
48+ Next, you have to mark the properties that should be encrypted with the ` #[SensitiveData ] ` attribute.
5049
5150``` php
5251use Patchlevel\EventSourcing\Identifier\Uuid;
5352use Patchlevel\Hydrator\Attribute\DataSubjectId;
54- use Patchlevel\Hydrator\Attribute\PersonalData ;
53+ use Patchlevel\Hydrator\Attribute\SensitiveData ;
5554
5655final class EmailChanged
5756{
5857 public function __construct(
5958 #[DataSubjectId]
6059 public readonly Uuid $profileId,
61- #[PersonalData ]
60+ #[SensitiveData ]
6261 public readonly string|null $email,
6362 ) {
6463 }
6564}
6665```
6766
6867::: tip
69- You can use the ` PersonalData ` in aggregates for snapshots too.
68+ You can use the ` SensitiveData ` in aggregates for snapshots too.
7069:::
7170
7271If the information could not be decrypted, then a fallback value will be used.
7372The default fallback value is ` null ` .
7473You can change this by setting the ` fallback ` parameter or using the ` fallbackCallable ` parameter.
7574
7675``` php
77- use Patchlevel\Hydrator\Attribute\PersonalData ;
76+ use Patchlevel\Hydrator\Attribute\SensitiveData ;
7877
7978final class ProfileChanged
8079{
8180 public function __construct(
8281 #[DataSubjectId]
8382 public readonly Uuid $profileId,
84- #[PersonalData (fallback: 'unknown')]
83+ #[SensitiveData (fallback: 'unknown')]
8584 public readonly string $name,
86- #[PersonalData (fallbackCallable: [self::class, 'createAnonymousEmail'])]
85+ #[SensitiveData (fallbackCallable: [self::class, 'createAnonymousEmail'])]
8786 public readonly string $email,
8887 ) {
8988 }
@@ -147,10 +146,10 @@ Now we have to put the whole thing together in a Personal Data Payload Cryptogra
147146
148147``` php
149148use Patchlevel\EventSourcing\Cryptography\Store\CipherKeyStore;
150- use Patchlevel\Hydrator\Cryptography\PersonalDataPayloadCryptographer ;
149+ use Patchlevel\Hydrator\Cryptography\SensitiveDataPayloadCryptographer ;
151150
152151/** @var CipherKeyStore $cipherKeyStore */
153- $cryptographer = PersonalDataPayloadCryptographer ::createWithDefaultSettings($cipherKeyStore);
152+ $cryptographer = SensitiveDataPayloadCryptographer ::createWithDefaultSettings($cipherKeyStore);
154153```
155154
156155::: tip
@@ -163,9 +162,9 @@ The last step is to integrate the cryptographer into the event store.
163162
164163``` php
165164use Patchlevel\EventSourcing\Serializer\DefaultEventSerializer;
166- use Patchlevel\Hydrator\Cryptography\PersonalDataPayloadCryptographer ;
165+ use Patchlevel\Hydrator\Cryptography\SensitiveDataPayloadCryptographer ;
167166
168- /** @var PersonalDataPayloadCryptographer $cryptographer */
167+ /** @var SensitiveDataPayloadCryptographer $cryptographer */
169168DefaultEventSerializer::createFromPaths(
170169 [__DIR__ . '/Events'],
171170 cryptographer: $cryptographer,
@@ -182,9 +181,9 @@ And for the snapshot store.
182181
183182``` php
184183use Patchlevel\EventSourcing\Snapshot\DefaultSnapshotStore;
185- use Patchlevel\Hydrator\Cryptography\PersonalDataPayloadCryptographer ;
184+ use Patchlevel\Hydrator\Cryptography\SensitiveDataPayloadCryptographer ;
186185
187- /** @var PersonalDataPayloadCryptographer $cryptographer */
186+ /** @var SensitiveDataPayloadCryptographer $cryptographer */
188187$snapshotStore = DefaultSnapshotStore::createDefault(
189188 [
190189 /* adapters... */
@@ -212,7 +211,7 @@ use Patchlevel\EventSourcing\Message\Message;
212211use Patchlevel\Hydrator\Cryptography\Store\CipherKeyStore;
213212
214213#[Processor('delete_personal_data')]
215- final class DeletePersonalDataProcessor
214+ final class DeleteSensitiveDataProcessor
216215{
217216 public function __construct(
218217 private readonly CipherKeyStore $cipherKeyStore,
0 commit comments