@@ -5,7 +5,7 @@ One main difference is that we don't save the current state, but only the indivi
55This means it is always possible to build the current state again from the events.
66
77::: note
8- The term aggregate itself comes from DDD and has nothing to do with event sourcing and can be used independently as a pattern.
8+ The term aggregate itself comes from DDD and has nothing to do with event sourcing and can be used independently as a pattern.
99You can find out more about Aggregates [ here] ( https://martinfowler.com/bliki/DDD_Aggregate.html ) .
1010:::
1111
@@ -44,7 +44,6 @@ final class Profile extends BasicAggregateRoot
4444 }
4545}
4646```
47-
4847::: warning
4948The aggregate is not yet finished and has only been built to the point that you can instantiate the object.
5049:::
@@ -77,7 +76,6 @@ final class CreateProfileHandler
7776 }
7877}
7978```
80-
8179::: warning
8280If you look in the database now, you would see that nothing has been saved.
8381This is because only events are stored in the database and as long as no events exist,
@@ -109,7 +107,6 @@ final class ProfileRegistered
109107 }
110108}
111109```
112-
113110::: note
114111You can find out more about events [ here] ( events.md ) .
115112:::
@@ -151,7 +148,6 @@ final class Profile extends BasicAggregateRoot
151148 }
152149}
153150```
154-
155151::: tip
156152Prefixing the apply methods with "apply" improves readability.
157153:::
@@ -185,7 +181,6 @@ final class NameChanged
185181 }
186182}
187183```
188-
189184::: note
190185Events should best be written in the past, as they describe a state that has happened.
191186:::
@@ -262,7 +257,6 @@ final class ChangeNameHandler
262257 }
263258}
264259```
265-
266260::: success
267261Our aggregate can now be changed and saved.
268262:::
@@ -309,9 +303,8 @@ final class Profile extends BasicAggregateRoot
309303 }
310304}
311305```
312-
313306::: tip
314- You don't necessarily need to define multiple ` Apply ` attributes with the event class
307+ You don't necessarily need to define multiple ` Apply ` attributes with the event class
315308if you define the event types in the method using a union type.
316309:::
317310
@@ -366,7 +359,6 @@ final class Profile extends BasicAggregateRoot
366359 }
367360}
368361```
369-
370362::: warning
371363When all events are suppressed, debugging becomes more difficult if you forget an apply method.
372364:::
@@ -399,7 +391,6 @@ final class PersonalInformation extends BasicAggregateRoot
399391{
400392}
401393```
402-
403394::: warning
404395You need to define the ` SharedApplyContext ` attribute on all aggregates that share the apply context.
405396:::
@@ -443,7 +434,6 @@ final class GuestList extends BasicAggregateRoot
443434 // ...
444435}
445436```
446-
447437::: tip
448438You can find more about splitting aggregates [ here] ( aggregate.md#splitting-aggregates ) .
449439:::
@@ -486,7 +476,6 @@ final class Profile extends BasicAggregateRoot
486476 }
487477}
488478```
489-
490479::: danger
491480Validations during "apply" should not happen, they will break the rebuilding of the aggregate!
492481Instead validate the data * before* the event will be recorded.
@@ -573,7 +562,6 @@ final class NameChanged
573562 }
574563}
575564```
576-
577565::: warning
578566You need to create a normalizer for the ` Name ` value object.
579567So the payload must be serializable and unserializable as json.
@@ -793,7 +781,6 @@ final class Shipping extends BasicAggregateRoot
793781 }
794782}
795783```
796-
797784::: tip
798785With the [ SharedApplyContext] ( aggregate.md#shared-apply-context ) attribute,
799786you can suppress missing applies for events that are handled by other aggregates.
@@ -842,7 +829,6 @@ final class Shipping extends BasicChildAggregate
842829 }
843830}
844831```
845-
846832::: warning
847833The apply method must be public, otherwise the root aggregate cannot call it.
848834:::
@@ -890,16 +876,15 @@ final class Order extends BasicAggregateRoot
890876 }
891877}
892878```
893-
894879## Auto Initialize
895880
896881::: experimental
897882This feature is still experimental and may change in the future.
898883Use it with caution.
899884:::
900885
901- Sometimes you want to be able to access an aggregate even if it has not yet been created in the system.
902- In this case, the aggregate should be automatically initialized if it cannot be found in the store.
886+ Sometimes you want to be able to access an aggregate even if it has not yet been created in the system.
887+ In this case, the aggregate should be automatically initialized if it cannot be found in the store.
903888To achieve this, the aggregate must mark the initialization method with the ` AutoInitialize ` attribute.
904889The method must be static, receives the aggregate ID as an argument and must return an instance of the aggregate.
905890
@@ -933,7 +918,6 @@ final class Profile extends BasicAggregateRoot
933918 }
934919}
935920```
936-
937921::: note
938922Recording events in the ` initialize ` method is optional but recommended.
939923:::
0 commit comments