Skip to content

Commit

Permalink
rename AggregateId attribute into Id, and fix typos in docs
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidBadura committed Jan 2, 2024
1 parent 27de103 commit 59b7587
Show file tree
Hide file tree
Showing 23 changed files with 58 additions and 58 deletions.
24 changes: 12 additions & 12 deletions docs/pages/aggregate.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ To make it easy to register with a name, we also add the `Aggregate` attribute.
use Patchlevel\EventSourcing\Aggregate\BasicAggregateRoot;
use Patchlevel\EventSourcing\Aggregate\UuidAggregateRootId;
use Patchlevel\EventSourcing\Attribute\Aggregate;
use Patchlevel\EventSourcing\Attribute\AggregateId;
use Patchlevel\EventSourcing\Attribute\Id;

#[Aggregate('profile')]
final class Profile extends BasicAggregateRoot
{
#[AggregateId]
#[Id]
private UuidAggregateRootId $id;

public static function register(UuidAggregateRootId $id): self
Expand Down Expand Up @@ -122,13 +122,13 @@ After we have defined the event, we have to adapt the profile aggregate:
use Patchlevel\EventSourcing\Aggregate\BasicAggregateRoot;
use Patchlevel\EventSourcing\Aggregate\UuidAggregateRootId;
use Patchlevel\EventSourcing\Attribute\Aggregate;
use Patchlevel\EventSourcing\Attribute\AggregateId;
use Patchlevel\EventSourcing\Attribute\Id;
use Patchlevel\EventSourcing\Attribute\Apply;

#[Aggregate('profile')]
final class Profile extends BasicAggregateRoot
{
#[AggregateId]
#[Id]
private UuidAggregateRootId $id;
private string $name;

Expand Down Expand Up @@ -199,13 +199,13 @@ This method then creates the event `NameChanged` and records it:
use Patchlevel\EventSourcing\Aggregate\BasicAggregateRoot;
use Patchlevel\EventSourcing\Aggregate\UuidAggregateRootId;
use Patchlevel\EventSourcing\Attribute\Aggregate;
use Patchlevel\EventSourcing\Attribute\AggregateId;
use Patchlevel\EventSourcing\Attribute\Id;
use Patchlevel\EventSourcing\Attribute\Apply;

#[Aggregate('profile')]
final class Profile extends BasicAggregateRoot
{
#[AggregateId]
#[Id]
private UuidAggregateRootId $id;
private string $name;

Expand Down Expand Up @@ -446,13 +446,13 @@ We can now use the value object `Name` in our aggregate:
use Patchlevel\EventSourcing\Aggregate\BasicAggregateRoot;
use Patchlevel\EventSourcing\Aggregate\UuidAggregateRootId;
use Patchlevel\EventSourcing\Attribute\Aggregate;
use Patchlevel\EventSourcing\Attribute\AggregateId;
use Patchlevel\EventSourcing\Attribute\Id;
use Patchlevel\EventSourcing\Attribute\Apply;

#[Aggregate('profile')]
final class Profile extends BasicAggregateRoot
{
#[AggregateId]
#[Id]
private UuidAggregateRootId $id;
private Name $name;

Expand Down Expand Up @@ -565,13 +565,13 @@ But you can pass this information by yourself.
use Patchlevel\EventSourcing\Aggregate\BasicAggregateRoot;
use Patchlevel\EventSourcing\Aggregate\UuidAggregateRootId;
use Patchlevel\EventSourcing\Attribute\Aggregate;
use Patchlevel\EventSourcing\Attribute\AggregateId;
use Patchlevel\EventSourcing\Attribute\Id;
use Patchlevel\EventSourcing\Attribute\Apply;

#[Aggregate('profile')]
final class Profile extends BasicAggregateRoot
{
#[AggregateId]
#[Id]
private UuidAggregateRootId $id;
private Name $name;
private DateTimeImmutable $registeredAt;
Expand All @@ -594,14 +594,14 @@ But if you still want to make sure that the time is "now" and not in the past or
use Patchlevel\EventSourcing\Aggregate\BasicAggregateRoot;
use Patchlevel\EventSourcing\Aggregate\UuidAggregateRootId;
use Patchlevel\EventSourcing\Attribute\Aggregate;
use Patchlevel\EventSourcing\Attribute\AggregateId;
use Patchlevel\EventSourcing\Attribute\Id;
use Patchlevel\EventSourcing\Attribute\Apply;
use Patchlevel\EventSourcing\Clock\Clock;

#[Aggregate('profile')]
final class Profile extends BasicAggregateRoot
{
#[AggregateId]
#[Id]
private UuidAggregateRootId $id;
private Name $name;
private DateTimeImmutable $registeredAt;
Expand Down
4 changes: 2 additions & 2 deletions docs/pages/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ use Patchlevel\EventSourcing\Aggregate\AggregateChanged;
use Patchlevel\EventSourcing\Aggregate\BasicAggregateRoot;
use Patchlevel\EventSourcing\Aggregate\UuidAggregateRootId;
use Patchlevel\EventSourcing\Attribute\Aggregate;
use Patchlevel\EventSourcing\Attribute\AggregateId;
use Patchlevel\EventSourcing\Attribute\Id;
use Patchlevel\EventSourcing\Attribute\Apply;

#[Aggregate('hotel')]
final class Hotel extends BasicAggregateRoot
{
#[AggregateId]
#[Id]
private UuidAggregateRootId $id;
private string $name;

Expand Down
8 changes: 4 additions & 4 deletions docs/pages/normalizer.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,16 +214,16 @@ final class DTO {
}
```

### ValueAggregateId
### BasicAggregateIdNormalizer

To normalize a `ValueAggregateRootId` one can use the `ValeAggregateIdNormalizer`.
To normalize a `ValueAggregateRootId` one can use the `BasicAggregateIdNormalizer`.

```php
use Patchlevel\EventSourcing\Aggregate\ValueAggregateRootId;
use Patchlevel\Hydrator\Normalizer\ValeAggregateIdNormalizer;
use Patchlevel\Hydrator\Normalizer\BasicAggregateIdNormalizer;

final class DTO {
#[ValeAggregateIdNormalizer]
#[BasicAggregateIdNormalizer]
public ValueAggregateRootId $id;
}
```
Expand Down
6 changes: 3 additions & 3 deletions docs/pages/snapshots.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,14 @@ You can define normalizers to bring the properties into the correct format.
use Patchlevel\EventSourcing\Aggregate\BasicAggregateRoot;
use Patchlevel\EventSourcing\Aggregate\UuidAggregateRootId;
use Patchlevel\EventSourcing\Attribute\Aggregate;
use Patchlevel\EventSourcing\Attribute\AggregateId;
use Patchlevel\EventSourcing\Attribute\Id;
use Patchlevel\EventSourcing\Attribute\Snapshot;

#[Aggregate('profile')]
#[Snapshot('default')]
final class Profile extends BasicAggregateRoot
{
#[AggregateId]
#[Id]
#[UuidAggregateRootIdNormalizer]
public UuidAggregateRootId $id;
public string $name,
Expand All @@ -99,7 +99,7 @@ final class Profile extends BasicAggregateRoot

!!! warning

In the end it has to be possible to serialize it as json. Also the aggregate ID.
In the end it the complete aggregate must be serializeable as json, also the aggregate Id.

!!! note

Expand Down
2 changes: 1 addition & 1 deletion src/Attribute/AggregateId.php → src/Attribute/Id.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
use Attribute;

#[Attribute(Attribute::TARGET_PROPERTY)]
final class AggregateId
final class Id
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use Patchlevel\EventSourcing\Aggregate\AggregateRoot;
use Patchlevel\EventSourcing\Attribute\Aggregate;
use Patchlevel\EventSourcing\Attribute\AggregateId;
use Patchlevel\EventSourcing\Attribute\Id;
use Patchlevel\EventSourcing\Attribute\Apply;
use Patchlevel\EventSourcing\Attribute\Snapshot as AttributeSnapshot;
use Patchlevel\EventSourcing\Attribute\SuppressMissingApply;
Expand Down Expand Up @@ -105,7 +105,7 @@ private function findIdProperty(ReflectionClass $reflector): string
$properties = $reflector->getProperties();

foreach ($properties as $property) {
$attributes = $property->getAttributes(AggregateId::class);
$attributes = $property->getAttributes(Id::class);

if ($attributes === []) {
continue;
Expand Down
4 changes: 2 additions & 2 deletions tests/Benchmark/BasicImplementation/Aggregate/Profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use Patchlevel\EventSourcing\Aggregate\BasicAggregateRoot;
use Patchlevel\EventSourcing\Attribute\Aggregate;
use Patchlevel\EventSourcing\Attribute\AggregateId;
use Patchlevel\EventSourcing\Attribute\Id;
use Patchlevel\EventSourcing\Attribute\Apply;
use Patchlevel\EventSourcing\Attribute\Snapshot;
use Patchlevel\EventSourcing\Tests\Benchmark\BasicImplementation\Events\NameChanged;
Expand All @@ -19,7 +19,7 @@
#[Snapshot('default')]
final class Profile extends BasicAggregateRoot
{
#[AggregateId]
#[Id]
#[ProfileIdNormalizer]
private ProfileId $id;
private string $name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use Patchlevel\EventSourcing\Aggregate\BasicAggregateRoot;
use Patchlevel\EventSourcing\Attribute\Aggregate;
use Patchlevel\EventSourcing\Attribute\AggregateId;
use Patchlevel\EventSourcing\Attribute\Id;
use Patchlevel\EventSourcing\Attribute\Apply;
use Patchlevel\EventSourcing\Tests\Integration\BankAccountSplitStream\AccountId;
use Patchlevel\EventSourcing\Tests\Integration\BankAccountSplitStream\Events\BalanceAdded;
Expand All @@ -16,7 +16,7 @@
#[Aggregate('profile')]
final class BankAccount extends BasicAggregateRoot
{
#[AggregateId]
#[Id]
private AccountId $id;
private string $name;
private int $balanceInCents;
Expand Down
4 changes: 2 additions & 2 deletions tests/Integration/BasicImplementation/Aggregate/Profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use Patchlevel\EventSourcing\Aggregate\BasicAggregateRoot;
use Patchlevel\EventSourcing\Attribute\Aggregate;
use Patchlevel\EventSourcing\Attribute\AggregateId;
use Patchlevel\EventSourcing\Attribute\Id;
use Patchlevel\EventSourcing\Attribute\Apply;
use Patchlevel\EventSourcing\Attribute\Snapshot;
use Patchlevel\EventSourcing\Tests\Integration\BasicImplementation\Events\ProfileCreated;
Expand All @@ -17,7 +17,7 @@
#[Snapshot('default', 100)]
final class Profile extends BasicAggregateRoot
{
#[AggregateId]
#[Id]
#[ProfileIdNormalizer]
private ProfileId $id;
private string $name;
Expand Down
4 changes: 2 additions & 2 deletions tests/Integration/Outbox/Aggregate/Profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use Patchlevel\EventSourcing\Aggregate\BasicAggregateRoot;
use Patchlevel\EventSourcing\Attribute\Aggregate;
use Patchlevel\EventSourcing\Attribute\AggregateId;
use Patchlevel\EventSourcing\Attribute\Id;
use Patchlevel\EventSourcing\Attribute\Apply;
use Patchlevel\EventSourcing\Attribute\Snapshot;
use Patchlevel\EventSourcing\Tests\Integration\Outbox\Events\ProfileCreated;
Expand All @@ -17,7 +17,7 @@
#[Snapshot('default', 100)]
final class Profile extends BasicAggregateRoot
{
#[AggregateId]
#[Id]
#[ProfileIdNormalizer]
private ProfileId $id;
private string $name;
Expand Down
4 changes: 2 additions & 2 deletions tests/Integration/Pipeline/Aggregate/Profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use Patchlevel\EventSourcing\Aggregate\BasicAggregateRoot;
use Patchlevel\EventSourcing\Attribute\Aggregate;
use Patchlevel\EventSourcing\Attribute\AggregateId;
use Patchlevel\EventSourcing\Attribute\Id;
use Patchlevel\EventSourcing\Attribute\Apply;
use Patchlevel\EventSourcing\Tests\Integration\Pipeline\Events\NewVisited;
use Patchlevel\EventSourcing\Tests\Integration\Pipeline\Events\OldVisited;
Expand All @@ -17,7 +17,7 @@
#[Aggregate('profile')]
final class Profile extends BasicAggregateRoot
{
#[AggregateId]
#[Id]
private ProfileId $id;
private bool $privacy;
private int $visited;
Expand Down
4 changes: 2 additions & 2 deletions tests/Integration/Projectionist/Aggregate/Profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use Patchlevel\EventSourcing\Aggregate\BasicAggregateRoot;
use Patchlevel\EventSourcing\Attribute\Aggregate;
use Patchlevel\EventSourcing\Attribute\AggregateId;
use Patchlevel\EventSourcing\Attribute\Id;
use Patchlevel\EventSourcing\Attribute\Apply;
use Patchlevel\EventSourcing\Tests\Integration\Projectionist\Events\ProfileCreated;
use Patchlevel\EventSourcing\Tests\Integration\Projectionist\Normalizer\ProfileIdNormalizer;
Expand All @@ -15,7 +15,7 @@
#[Aggregate('profile')]
final class Profile extends BasicAggregateRoot
{
#[AggregateId]
#[Id]
#[ProfileIdNormalizer]
private ProfileId $id;
private string $name;
Expand Down
4 changes: 2 additions & 2 deletions tests/Integration/Store/Profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use Patchlevel\EventSourcing\Aggregate\BasicAggregateRoot;
use Patchlevel\EventSourcing\Attribute\Aggregate;
use Patchlevel\EventSourcing\Attribute\AggregateId;
use Patchlevel\EventSourcing\Attribute\Id;
use Patchlevel\EventSourcing\Attribute\Apply;
use Patchlevel\EventSourcing\Tests\Integration\Projectionist\Events\ProfileCreated;
use Patchlevel\EventSourcing\Tests\Integration\Projectionist\Normalizer\ProfileIdNormalizer;
Expand All @@ -15,7 +15,7 @@
#[Aggregate('profile')]
final class Profile extends BasicAggregateRoot
{
#[AggregateId]
#[Id]
#[ProfileIdNormalizer]
private ProfileId $id;
private string $name;
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/Fixture/Profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@

use Patchlevel\EventSourcing\Aggregate\BasicAggregateRoot;
use Patchlevel\EventSourcing\Attribute\Aggregate;
use Patchlevel\EventSourcing\Attribute\AggregateId;
use Patchlevel\EventSourcing\Attribute\Id;
use Patchlevel\EventSourcing\Attribute\Apply;
use Patchlevel\EventSourcing\Attribute\SuppressMissingApply;

#[Aggregate('profile')]
#[SuppressMissingApply([MessageDeleted::class])]
final class Profile extends BasicAggregateRoot
{
#[AggregateId]
#[Id]
private ProfileId $id;
private Email $email;
private int $visits = 0;
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/Fixture/ProfileInvalid.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@

use Patchlevel\EventSourcing\Aggregate\BasicAggregateRoot;
use Patchlevel\EventSourcing\Attribute\Aggregate;
use Patchlevel\EventSourcing\Attribute\AggregateId;
use Patchlevel\EventSourcing\Attribute\Id;
use Patchlevel\EventSourcing\Attribute\Apply;

#[Aggregate(ProfileInvalid::class)]
final class ProfileInvalid extends BasicAggregateRoot
{
#[AggregateId]
#[Id]
private ProfileId $id;
private Email $email;

Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/Fixture/ProfileWithBrokenApplyBothUsage.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@

use Patchlevel\EventSourcing\Aggregate\BasicAggregateRoot;
use Patchlevel\EventSourcing\Attribute\Aggregate;
use Patchlevel\EventSourcing\Attribute\AggregateId;
use Patchlevel\EventSourcing\Attribute\Id;
use Patchlevel\EventSourcing\Attribute\Apply;

#[Aggregate(ProfileWithBrokenApplyBothUsage::class)]
final class ProfileWithBrokenApplyBothUsage extends BasicAggregateRoot
{
#[AggregateId]
#[Id]
private ProfileId $id;

#[Apply(ProfileCreated::class)]
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/Fixture/ProfileWithBrokenApplyIntersection.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@

use Patchlevel\EventSourcing\Aggregate\BasicAggregateRoot;
use Patchlevel\EventSourcing\Attribute\Aggregate;
use Patchlevel\EventSourcing\Attribute\AggregateId;
use Patchlevel\EventSourcing\Attribute\Id;
use Patchlevel\EventSourcing\Attribute\Apply;

#[Aggregate(ProfileWithBrokenApplyIntersection::class)]
final class ProfileWithBrokenApplyIntersection extends BasicAggregateRoot
{
#[AggregateId]
#[Id]
private ProfileId $id;

#[Apply]
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/Fixture/ProfileWithBrokenApplyMultipleApply.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@

use Patchlevel\EventSourcing\Aggregate\BasicAggregateRoot;
use Patchlevel\EventSourcing\Attribute\Aggregate;
use Patchlevel\EventSourcing\Attribute\AggregateId;
use Patchlevel\EventSourcing\Attribute\Id;
use Patchlevel\EventSourcing\Attribute\Apply;

#[Aggregate(ProfileWithBrokenApplyMultipleApply::class)]
final class ProfileWithBrokenApplyMultipleApply extends BasicAggregateRoot
{
#[AggregateId]
#[Id]
private ProfileId $id;

#[Apply]
Expand Down
Loading

0 comments on commit 59b7587

Please sign in to comment.