Skip to content

Commit 28d5d9e

Browse files
committed
upgrade hydrator 2.0
1 parent 292b76a commit 28d5d9e

14 files changed

Lines changed: 282 additions & 273 deletions

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"php": "~8.2.0 || ~8.3.0 || ~8.4.0",
2323
"doctrine/dbal": "^4.0.0",
2424
"doctrine/migrations": "^3.3.2",
25-
"patchlevel/hydrator": "^1.8.0",
25+
"patchlevel/hydrator": "^2.0.x-dev",
2626
"patchlevel/worker": "^1.4.0",
2727
"psr/cache": "^2.0.0 || ^3.0.0",
2828
"psr/clock": "^1.0",

composer.lock

Lines changed: 234 additions & 225 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/mkdocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ nav:
105105
- Identifier: identifier.md
106106
- Normalizer: normalizer.md
107107
- Snapshots: snapshots.md
108-
- Personal Data: personal_data.md
108+
- Sensitive Data: sensitive_data.md
109109
- Upcasting: upcasting.md
110110
- Message Decorator: message_decorator.md
111111
- Split Stream: split_stream.md

docs/pages/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ powered by the reliable Doctrine ecosystem and focused on developer experience.
1111
* Automatic [snapshot](snapshots.md)-system to boost your performance
1212
* [Split](split_stream.md) big aggregates into multiple streams
1313
* Versioned and managed lifecycle of [subscriptions](subscription.md) like projections and processors
14-
* Safe usage of [Personal Data](personal_data.md) with crypto-shredding
14+
* Safe usage of [Personal Data](sensitive_data.md) with crypto-shredding
1515
* Smooth [upcasting](upcasting.md) of old events
1616
* Simple setup with [scheme management](store.md) and [doctrine migration](store.md)
1717
* Built in [cli commands](cli.md) with [symfony](https://symfony.com/)

docs/pages/normalizer.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ final class CreateHotel
101101
```
102102
!!! note
103103

104-
If you have personal data, you can use [crypto-shredding](personal_data.md).
104+
If you have personal data, you can use [crypto-shredding](sensitive_data.md).
105105

106106
### Aggregate
107107

@@ -459,4 +459,4 @@ final class DTO
459459
* [How to define aggregates](aggregate.md)
460460
* [How to define events](events.md)
461461
* [How to snapshot aggregates](snapshots.md)
462-
* [How to work with personal data](personal_data.md)
462+
* [How to work with personal data](sensitive_data.md)
Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Personal Data (GDPR)
1+
# Sensitive Data
22

33
According to GDPR, personal data must be able to be deleted upon request.
44
But here we have the problem that our events are immutable and we cannot easily manipulate the event store.
@@ -43,45 +43,45 @@ final class EmailChanged
4343

4444
You can use the `DataSubjectId` in aggregates for snapshots too.
4545

46-
### PersonalData
46+
### SensitiveData
4747

48-
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.
4949

5050
```php
5151
use Patchlevel\EventSourcing\Identifier\Uuid;
5252
use Patchlevel\Hydrator\Attribute\DataSubjectId;
53-
use Patchlevel\Hydrator\Attribute\PersonalData;
53+
use Patchlevel\Hydrator\Attribute\SensitiveData;
5454

5555
final class EmailChanged
5656
{
5757
public function __construct(
5858
#[DataSubjectId]
5959
public readonly Uuid $profileId,
60-
#[PersonalData]
60+
#[SensitiveData]
6161
public readonly string|null $email,
6262
) {
6363
}
6464
}
6565
```
6666
!!! tip
6767

68-
You can use the `PersonalData` in aggregates for snapshots too.
68+
You can use the `SensitiveData` in aggregates for snapshots too.
6969

7070
If the information could not be decrypted, then a fallback value will be used.
7171
The default fallback value is `null`.
7272
You can change this by setting the `fallback` parameter or using the `fallbackCallable` parameter.
7373

7474
```php
75-
use Patchlevel\Hydrator\Attribute\PersonalData;
75+
use Patchlevel\Hydrator\Attribute\SensitiveData;
7676

7777
final class ProfileChanged
7878
{
7979
public function __construct(
8080
#[DataSubjectId]
8181
public readonly Uuid $profileId,
82-
#[PersonalData(fallback: 'unknown')]
82+
#[SensitiveData(fallback: 'unknown')]
8383
public readonly string $name,
84-
#[PersonalData(fallbackCallable: [self::class, 'createAnonymousEmail'])]
84+
#[SensitiveData(fallbackCallable: [self::class, 'createAnonymousEmail'])]
8585
public readonly string $email,
8686
) {
8787
}
@@ -144,10 +144,10 @@ Now we have to put the whole thing together in a Personal Data Payload Cryptogra
144144

145145
```php
146146
use Patchlevel\EventSourcing\Cryptography\Store\CipherKeyStore;
147-
use Patchlevel\Hydrator\Cryptography\PersonalDataPayloadCryptographer;
147+
use Patchlevel\Hydrator\Cryptography\SensitiveDataPayloadCryptographer;
148148

149149
/** @var CipherKeyStore $cipherKeyStore */
150-
$cryptographer = PersonalDataPayloadCryptographer::createWithDefaultSettings($cipherKeyStore);
150+
$cryptographer = SensitiveDataPayloadCryptographer::createWithDefaultSettings($cipherKeyStore);
151151
```
152152
!!! tip
153153

@@ -159,9 +159,9 @@ The last step is to integrate the cryptographer into the event store.
159159

160160
```php
161161
use Patchlevel\EventSourcing\Serializer\DefaultEventSerializer;
162-
use Patchlevel\Hydrator\Cryptography\PersonalDataPayloadCryptographer;
162+
use Patchlevel\Hydrator\Cryptography\SensitiveDataPayloadCryptographer;
163163

164-
/** @var PersonalDataPayloadCryptographer $cryptographer */
164+
/** @var SensitiveDataPayloadCryptographer $cryptographer */
165165
DefaultEventSerializer::createFromPaths(
166166
[__DIR__ . '/Events'],
167167
cryptographer: $cryptographer,
@@ -177,9 +177,9 @@ And for the snapshot store.
177177

178178
```php
179179
use Patchlevel\EventSourcing\Snapshot\DefaultSnapshotStore;
180-
use Patchlevel\Hydrator\Cryptography\PersonalDataPayloadCryptographer;
180+
use Patchlevel\Hydrator\Cryptography\SensitiveDataPayloadCryptographer;
181181

182-
/** @var PersonalDataPayloadCryptographer $cryptographer */
182+
/** @var SensitiveDataPayloadCryptographer $cryptographer */
183183
$snapshotStore = DefaultSnapshotStore::createDefault(
184184
[
185185
/* adapters... */
@@ -206,7 +206,7 @@ use Patchlevel\EventSourcing\Message\Message;
206206
use Patchlevel\Hydrator\Cryptography\Store\CipherKeyStore;
207207

208208
#[Processor('delete_personal_data')]
209-
final class DeletePersonalDataProcessor
209+
final class DeleteSensitiveDataProcessor
210210
{
211211
public function __construct(
212212
private readonly CipherKeyStore $cipherKeyStore,

docs/pages/snapshots.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,4 +261,4 @@ And if the version is no longer correct and the snapshot is therefore invalid, t
261261
* [How to define aggregates](aggregate.md)
262262
* [How to store and load aggregates](repository.md)
263263
* [How to split streams](split_stream.md)
264-
* [How to work with personal data](personal_data.md)
264+
* [How to work with personal data](sensitive_data.md)

tests/Integration/PersonalData/Events/NameChanged.php renamed to tests/Integration/SensitiveData/Events/NameChanged.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@
22

33
declare(strict_types=1);
44

5-
namespace Patchlevel\EventSourcing\Tests\Integration\PersonalData\Events;
5+
namespace Patchlevel\EventSourcing\Tests\Integration\SensitiveData\Events;
66

77
use Patchlevel\EventSourcing\Attribute\Event;
8-
use Patchlevel\EventSourcing\Tests\Integration\PersonalData\ProfileId;
8+
use Patchlevel\EventSourcing\Tests\Integration\SensitiveData\ProfileId;
99
use Patchlevel\Hydrator\Attribute\DataSubjectId;
10-
use Patchlevel\Hydrator\Attribute\PersonalData;
10+
use Patchlevel\Hydrator\Attribute\SensitiveData;
1111

1212
#[Event('profile.name_changed')]
1313
final class NameChanged
1414
{
1515
public function __construct(
1616
#[DataSubjectId]
1717
public readonly ProfileId $aggregateId,
18-
#[PersonalData(fallback: 'unknown')]
18+
#[SensitiveData(fallback: 'unknown')]
1919
public readonly string $name,
2020
) {
2121
}

tests/Integration/PersonalData/Events/PersonalDataRemoved.php renamed to tests/Integration/SensitiveData/Events/PersonalDataRemoved.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
declare(strict_types=1);
44

5-
namespace Patchlevel\EventSourcing\Tests\Integration\PersonalData\Events;
5+
namespace Patchlevel\EventSourcing\Tests\Integration\SensitiveData\Events;
66

77
use Patchlevel\EventSourcing\Attribute\Event;
8-
use Patchlevel\EventSourcing\Tests\Integration\PersonalData\ProfileId;
8+
use Patchlevel\EventSourcing\Tests\Integration\SensitiveData\ProfileId;
99

1010
#[Event('profile.personal_data_removed')]
1111
final class PersonalDataRemoved

tests/Integration/PersonalData/Events/ProfileCreated.php renamed to tests/Integration/SensitiveData/Events/ProfileCreated.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@
22

33
declare(strict_types=1);
44

5-
namespace Patchlevel\EventSourcing\Tests\Integration\PersonalData\Events;
5+
namespace Patchlevel\EventSourcing\Tests\Integration\SensitiveData\Events;
66

77
use Patchlevel\EventSourcing\Attribute\Event;
8-
use Patchlevel\EventSourcing\Tests\Integration\PersonalData\ProfileId;
8+
use Patchlevel\EventSourcing\Tests\Integration\SensitiveData\ProfileId;
99
use Patchlevel\Hydrator\Attribute\DataSubjectId;
10-
use Patchlevel\Hydrator\Attribute\PersonalData;
10+
use Patchlevel\Hydrator\Attribute\SensitiveData;
1111

1212
#[Event('profile.created')]
1313
final class ProfileCreated
1414
{
1515
public function __construct(
1616
#[DataSubjectId]
1717
public ProfileId $profileId,
18-
#[PersonalData(fallback: 'unknown')]
18+
#[SensitiveData(fallback: 'unknown')]
1919
public string $name,
2020
) {
2121
}

0 commit comments

Comments
 (0)