Skip to content

Commit 16c0172

Browse files
committed
add identifier
1 parent f047111 commit 16c0172

59 files changed

Lines changed: 212 additions & 238 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/mkdocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ nav:
101101
- Event Bus: event_bus.md
102102
- Query Bus: query_bus.md
103103
- Advanced:
104-
- Aggregate ID: aggregate_id.md
104+
- Identifier: identifier.md
105105
- Normalizer: normalizer.md
106106
- Snapshots: snapshots.md
107107
- Personal Data: personal_data.md

docs/pages/UPGRADE-4.0.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ $subscriptionEngine = new DefaultSubscriptionEngine(
6161
RetryStrategyRepository::withDefault($retryStrategy),
6262
);
6363
```
64-
6564
## Store
6665

6766
### DoctrineDbalStore
@@ -95,4 +94,4 @@ and replaced with the following headers:
9594
### DoctrineSchemaSubscriber
9695

9796
The `Patchlevel\EventSourcing\Schema\DoctrineSchemaSubscriber` has been removed.
98-
use the `Patchlevel\EventSourcing\Schema\DoctrineSchemaListener` instead.
97+
use the `Patchlevel\EventSourcing\Schema\DoctrineSchemaListener` instead.

docs/pages/aggregate.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ To make it easy to register with a name, we also add the `Aggregate` attribute.
2424

2525
```php
2626
use Patchlevel\EventSourcing\Aggregate\BasicAggregateRoot;
27-
use Patchlevel\EventSourcing\Aggregate\Uuid;
2827
use Patchlevel\EventSourcing\Attribute\Aggregate;
2928
use Patchlevel\EventSourcing\Attribute\Id;
29+
use Patchlevel\EventSourcing\Identifier\Uuid;
3030

3131
#[Aggregate('profile')]
3232
final class Profile extends BasicAggregateRoot
@@ -50,7 +50,7 @@ final class Profile extends BasicAggregateRoot
5050

5151
!!! tip
5252

53-
Find out more about aggregate IDs [here](./aggregate_id.md).
53+
Find out more about aggregate IDs [here](./identifier.md).
5454

5555
We use a so-called named constructor here to create an object of the AggregateRoot.
5656
The constructor itself is protected and cannot be called from outside.
@@ -94,8 +94,8 @@ For our aggregate we create the Event `ProfileRegistered` with an ID and a name.
9494
We also give the event a unique name using the `Event` attribute.
9595

9696
```php
97-
use Patchlevel\EventSourcing\Aggregate\Uuid;
9897
use Patchlevel\EventSourcing\Attribute\Event;
98+
use Patchlevel\EventSourcing\Identifier\Uuid;
9999

100100
#[Event('profile.registered')]
101101
final class ProfileRegistered
@@ -115,10 +115,10 @@ After we have defined the event, we have to adapt the profile aggregate:
115115

116116
```php
117117
use Patchlevel\EventSourcing\Aggregate\BasicAggregateRoot;
118-
use Patchlevel\EventSourcing\Aggregate\Uuid;
119118
use Patchlevel\EventSourcing\Attribute\Aggregate;
120119
use Patchlevel\EventSourcing\Attribute\Apply;
121120
use Patchlevel\EventSourcing\Attribute\Id;
121+
use Patchlevel\EventSourcing\Identifier\Uuid;
122122

123123
#[Aggregate('profile')]
124124
final class Profile extends BasicAggregateRoot
@@ -190,10 +190,10 @@ This method then creates the event `NameChanged` and records it:
190190

191191
```php
192192
use Patchlevel\EventSourcing\Aggregate\BasicAggregateRoot;
193-
use Patchlevel\EventSourcing\Aggregate\Uuid;
194193
use Patchlevel\EventSourcing\Attribute\Aggregate;
195194
use Patchlevel\EventSourcing\Attribute\Apply;
196195
use Patchlevel\EventSourcing\Attribute\Id;
196+
use Patchlevel\EventSourcing\Identifier\Uuid;
197197

198198
#[Aggregate('profile')]
199199
final class Profile extends BasicAggregateRoot
@@ -466,10 +466,10 @@ We can now use the value object `Name` in our aggregate:
466466

467467
```php
468468
use Patchlevel\EventSourcing\Aggregate\BasicAggregateRoot;
469-
use Patchlevel\EventSourcing\Aggregate\Uuid;
470469
use Patchlevel\EventSourcing\Attribute\Aggregate;
471470
use Patchlevel\EventSourcing\Attribute\Apply;
472471
use Patchlevel\EventSourcing\Attribute\Id;
472+
use Patchlevel\EventSourcing\Identifier\Uuid;
473473

474474
#[Aggregate('profile')]
475475
final class Profile extends BasicAggregateRoot
@@ -587,9 +587,9 @@ But you can pass this information by yourself.
587587

588588
```php
589589
use Patchlevel\EventSourcing\Aggregate\BasicAggregateRoot;
590-
use Patchlevel\EventSourcing\Aggregate\Uuid;
591590
use Patchlevel\EventSourcing\Attribute\Aggregate;
592591
use Patchlevel\EventSourcing\Attribute\Id;
592+
use Patchlevel\EventSourcing\Identifier\Uuid;
593593

594594
#[Aggregate('profile')]
595595
final class Profile extends BasicAggregateRoot
@@ -614,9 +614,9 @@ But if you still want to make sure that the time is "now" and not in the past or
614614

615615
```php
616616
use Patchlevel\EventSourcing\Aggregate\BasicAggregateRoot;
617-
use Patchlevel\EventSourcing\Aggregate\Uuid;
618617
use Patchlevel\EventSourcing\Attribute\Aggregate;
619618
use Patchlevel\EventSourcing\Attribute\Id;
619+
use Patchlevel\EventSourcing\Identifier\Uuid;
620620
use Psr\Clock\ClockInterface;
621621

622622
#[Aggregate('profile')]
@@ -663,10 +663,10 @@ The order handle the order itself and the shipping handle the shipping of the or
663663

664664
```php
665665
use Patchlevel\EventSourcing\Aggregate\BasicAggregateRoot;
666-
use Patchlevel\EventSourcing\Aggregate\Uuid;
667666
use Patchlevel\EventSourcing\Attribute\Aggregate;
668667
use Patchlevel\EventSourcing\Attribute\Apply;
669668
use Patchlevel\EventSourcing\Attribute\Id;
669+
use Patchlevel\EventSourcing\Identifier\Uuid;
670670

671671
#[Aggregate('order')]
672672
final class Order extends BasicAggregateRoot
@@ -694,11 +694,11 @@ In this case, the `Shipping` aggregate listens to the `OrderCreated` event to in
694694

695695
```php
696696
use Patchlevel\EventSourcing\Aggregate\BasicAggregateRoot;
697-
use Patchlevel\EventSourcing\Aggregate\Uuid;
698697
use Patchlevel\EventSourcing\Attribute\Aggregate;
699698
use Patchlevel\EventSourcing\Attribute\Apply;
700699
use Patchlevel\EventSourcing\Attribute\Id;
701700
use Patchlevel\EventSourcing\Attribute\Stream;
701+
use Patchlevel\EventSourcing\Identifier\Uuid;
702702

703703
#[Aggregate('shipping')]
704704
#[Stream(Order::class)]
@@ -756,7 +756,7 @@ $aggregateRegistry = (new AttributeAggregateRootRegistryFactory())->create([/* p
756756
```
757757
## Learn more
758758

759-
* [How to create own aggregate id](aggregate_id.md)
759+
* [How to create own aggregate id](identifier.md)
760760
* [How to store and load aggregates](repository.md)
761761
* [How to snapshot aggregates](snapshots.md)
762762
* [How to create Projections](subscription.md)

docs/pages/command_bus.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,5 +362,5 @@ $provider = new ChainHandlerProvider([
362362
* [How to use aggregates](aggregate.md)
363363
* [How to use events](events.md)
364364
* [How to use clock](clock.md)
365-
* [How to use aggregate id](aggregate_id.md)
365+
* [How to use aggregate id](identifier.md)
366366
* [How to use query bus](query_bus.md)

docs/pages/events.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ You can do that too. However, you must define a normalizer for this
8989
so that the library knows how to write this data to the database and load it again.
9090

9191
```php
92-
use Patchlevel\EventSourcing\Aggregate\Uuid;
9392
use Patchlevel\EventSourcing\Attribute\Event;
93+
use Patchlevel\EventSourcing\Identifier\Uuid;
9494
use Patchlevel\EventSourcing\Serializer\Normalizer\IdNormalizer;
9595
use Patchlevel\Hydrator\Normalizer\DateTimeImmutableNormalizer;
9696

docs/pages/getting_started.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ First we define the events that happen in our system.
1010
A hotel can be created with a `name` and a `id`:
1111

1212
```php
13-
use Patchlevel\EventSourcing\Aggregate\Uuid;
1413
use Patchlevel\EventSourcing\Attribute\Event;
14+
use Patchlevel\EventSourcing\Identifier\Uuid;
1515

1616
#[Event('hotel.created')]
1717
final class HotelCreated
@@ -65,10 +65,10 @@ Last but not least, we need the associated apply methods to change the state.
6565

6666
```php
6767
use Patchlevel\EventSourcing\Aggregate\BasicAggregateRoot;
68-
use Patchlevel\EventSourcing\Aggregate\Uuid;
6968
use Patchlevel\EventSourcing\Attribute\Aggregate;
7069
use Patchlevel\EventSourcing\Attribute\Apply;
7170
use Patchlevel\EventSourcing\Attribute\Id;
71+
use Patchlevel\EventSourcing\Identifier\Uuid;
7272

7373
#[Aggregate('hotel')]
7474
final class Hotel extends BasicAggregateRoot
@@ -155,11 +155,11 @@ Each projector is then responsible for a specific projection.
155155

156156
```php
157157
use Doctrine\DBAL\Connection;
158-
use Patchlevel\EventSourcing\Aggregate\Uuid;
159158
use Patchlevel\EventSourcing\Attribute\Projector;
160159
use Patchlevel\EventSourcing\Attribute\Setup;
161160
use Patchlevel\EventSourcing\Attribute\Subscribe;
162161
use Patchlevel\EventSourcing\Attribute\Teardown;
162+
use Patchlevel\EventSourcing\Identifier\Uuid;
163163
use Patchlevel\EventSourcing\Subscription\Subscriber\SubscriberUtil;
164164

165165
#[Projector('hotel')]
@@ -370,7 +370,7 @@ $engine->setup(skipBooting: true);
370370
We are now ready to use the Event Sourcing System. We can load, change and save aggregates.
371371

372372
```php
373-
use Patchlevel\EventSourcing\Aggregate\Uuid;
373+
use Patchlevel\EventSourcing\Identifier\Uuid;
374374
use Patchlevel\EventSourcing\Repository\Repository;
375375

376376
$hotel1 = Hotel::create(Uuid::generate(), 'HOTEL');
@@ -390,7 +390,7 @@ $hotels = $hotelProjection->getHotels();
390390
!!! note
391391

392392
You can also use other forms of IDs such as uuid version 6 or a custom format.
393-
You can find more about this [here](aggregate_id.md).
393+
You can find more about this [here](identifier.md).
394394

395395
## Result
396396

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Aggregate ID
1+
# Identifier
22

33
The `aggregate id` is a unique identifier for an aggregate.
44
It is used to identify the aggregate in the event store.
@@ -22,9 +22,9 @@ You can use it like this:
2222

2323
```php
2424
use Patchlevel\EventSourcing\Aggregate\BasicAggregateRoot;
25-
use Patchlevel\EventSourcing\Aggregate\Uuid;
2625
use Patchlevel\EventSourcing\Attribute\Aggregate;
2726
use Patchlevel\EventSourcing\Attribute\Id;
27+
use Patchlevel\EventSourcing\Identifier\Uuid;
2828

2929
#[Aggregate('profile')]
3030
final class Profile extends BasicAggregateRoot
@@ -36,7 +36,7 @@ final class Profile extends BasicAggregateRoot
3636
You have multiple options for generating an uuid:
3737

3838
```php
39-
use Patchlevel\EventSourcing\Aggregate\Uuid;
39+
use Patchlevel\EventSourcing\Identifier\Uuid;
4040

4141
$uuid = Uuid::generate();
4242
$uuid = Uuid::fromString('d6e8d7a0-4b0b-4e6a-8a9a-3a0b2d9d0e4e');
@@ -53,9 +53,9 @@ This is a value object that holds any string.
5353

5454
```php
5555
use Patchlevel\EventSourcing\Aggregate\BasicAggregateRoot;
56-
use Patchlevel\EventSourcing\Aggregate\CustomId;
5756
use Patchlevel\EventSourcing\Attribute\Aggregate;
5857
use Patchlevel\EventSourcing\Attribute\Id;
58+
use Patchlevel\EventSourcing\Identifier\CustomId;
5959

6060
#[Aggregate('profile')]
6161
final class Profile extends BasicAggregateRoot
@@ -73,7 +73,7 @@ final class Profile extends BasicAggregateRoot
7373
So you can use any string as an id:
7474

7575
```php
76-
use Patchlevel\EventSourcing\Aggregate\CustomId;
76+
use Patchlevel\EventSourcing\Identifier\CustomId;
7777

7878
$id = CustomId::fromString('my-id');
7979
```
@@ -84,9 +84,9 @@ This allows you to ensure that the correct id is always used.
8484
The whole thing looks like this:
8585

8686
```php
87-
use Patchlevel\EventSourcing\Aggregate\AggregateRootId;
87+
use Patchlevel\EventSourcing\Identifier\Identifier;
8888

89-
class ProfileId implements AggregateRootId
89+
class ProfileId implements Identifier
9090
{
9191
private function __construct(
9292
private readonly string $id,
@@ -98,7 +98,7 @@ class ProfileId implements AggregateRootId
9898
return $this->id;
9999
}
100100

101-
public static function fromString(string $id): self
101+
public static function fromString(string $id): static
102102
{
103103
return new self($id);
104104
}
@@ -122,21 +122,21 @@ We also offer you some traits, so that you don't have to implement the `Aggregat
122122
Here for the uuid:
123123

124124
```php
125-
use Patchlevel\EventSourcing\Aggregate\AggregateRootId;
126-
use Patchlevel\EventSourcing\Aggregate\RamseyUuidV7Behaviour;
125+
use Patchlevel\EventSourcing\Identifier\Identifier;
126+
use Patchlevel\EventSourcing\Identifier\RamseyUuidV7Behaviour;
127127

128-
class ProfileId implements AggregateRootId
128+
class ProfileId implements Identifier
129129
{
130130
use RamseyUuidV7Behaviour;
131131
}
132132
```
133133
Or for the custom id:
134134

135135
```php
136-
use Patchlevel\EventSourcing\Aggregate\AggregateRootId;
137-
use Patchlevel\EventSourcing\Aggregate\CustomIdBehaviour;
136+
use Patchlevel\EventSourcing\Identifier\CustomIdBehaviour;
137+
use Patchlevel\EventSourcing\Identifier\Identifier;
138138

139-
class ProfileId implements AggregateRootId
139+
class ProfileId implements Identifier
140140
{
141141
use CustomIdBehaviour;
142142
}

docs/pages/normalizer.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ final class DTO
275275
If you have your own AggregateRootId, you can use the `IdNormalizer`.
276276

277277
```php
278-
use Patchlevel\EventSourcing\Aggregate\Uuid;
278+
use Patchlevel\EventSourcing\Identifier\Uuid;
279279
use Patchlevel\EventSourcing\Serializer\Normalizer\IdNormalizer;
280280

281281
final class DTO
@@ -291,7 +291,7 @@ final class DTO
291291
Optional you can also define the type of the id.
292292

293293
```php
294-
use Patchlevel\EventSourcing\Aggregate\Uuid;
294+
use Patchlevel\EventSourcing\Identifier\Uuid;
295295
use Patchlevel\EventSourcing\Serializer\Normalizer\IdNormalizer;
296296

297297
final class DTO

docs/pages/personal_data.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ In order for the correct key to be used, a subject ID must be defined.
2626
Without Subject Id, no personal data can be encrypted or decrypted.
2727

2828
```php
29-
use Patchlevel\EventSourcing\Aggregate\Uuid;
29+
use Patchlevel\EventSourcing\Identifier\Uuid;
3030
use Patchlevel\Hydrator\Attribute\DataSubjectId;
3131

3232
final class EmailChanged
@@ -48,7 +48,7 @@ final class EmailChanged
4848
Next, you have to mark the properties that should be encrypted with the `#[PersonalData]` attribute.
4949

5050
```php
51-
use Patchlevel\EventSourcing\Aggregate\Uuid;
51+
use Patchlevel\EventSourcing\Identifier\Uuid;
5252
use Patchlevel\Hydrator\Attribute\DataSubjectId;
5353
use Patchlevel\Hydrator\Attribute\PersonalData;
5454

docs/pages/repository.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ All new events that have not yet been written to the database are fetched from t
154154
These events are then also append to the database.
155155

156156
```php
157-
use Patchlevel\EventSourcing\Aggregate\Uuid;
157+
use Patchlevel\EventSourcing\Identifier\Uuid;
158158
use Patchlevel\EventSourcing\Repository\Repository;
159159

160160
$id = Uuid::generate();
@@ -187,7 +187,7 @@ An `aggregate` can be loaded using the `load` method.
187187
All events for the aggregate are loaded from the database and the current state is rebuilt.
188188

189189
```php
190-
use Patchlevel\EventSourcing\Aggregate\Uuid;
190+
use Patchlevel\EventSourcing\Identifier\Uuid;
191191
use Patchlevel\EventSourcing\Repository\Repository;
192192

193193
$id = Uuid::fromString('229286ff-6f95-4df6-bc72-0a239fe7b284');
@@ -210,7 +210,7 @@ You can also check whether an `aggregate` with a certain id exists.
210210
It is checked whether any event with this id exists in the database.
211211

212212
```php
213-
use Patchlevel\EventSourcing\Aggregate\Uuid;
213+
use Patchlevel\EventSourcing\Identifier\Uuid;
214214
use Patchlevel\EventSourcing\Repository\Repository;
215215

216216
$id = Uuid::fromString('229286ff-6f95-4df6-bc72-0a239fe7b284');

0 commit comments

Comments
 (0)