1
1
# Migrating from 0.8.0
2
2
3
- Due to [ the future of prooph components] ( https://www.sasaprolic.com/2018/08/the-future-of-prooph-components.html )
4
- and [ ES/Service-Bus discussion] ( https://github.com/prooph/event-sourcing/issues/90 )
5
- , ` prooph/event-sourcing ` dependency was dropped for this bundle after ` 0.8.0 ` . You can still use it, but additional work
6
- must be done after upgrading this bundle to ` 0.9.0 ` or further.
3
+ Due to [ the future of prooph components] ( https://www.sasaprolic.com/2018/08/the-future-of-prooph-components.html )
4
+ and [ ES/Service-Bus discussion] ( https://github.com/prooph/event-sourcing/issues/90 )
5
+ , ` prooph/event-sourcing ` dependency was dropped for this bundle after ` 0.8.0 ` . You can still use it, but additional
6
+ work must be done after upgrading this bundle to ` 0.9.0 ` or further.
7
7
8
8
## Explicit installation of event sourcing component
9
9
@@ -15,8 +15,8 @@ $ composer install prooph/event-sourcing
15
15
16
16
## Explicit definition of aggregate repositories
17
17
18
- Aggregate repositories were part of ` prooph/event-sourcing ` and without it , bundle will no longer register repositories
19
- as a services. You have to configure those by yourself. Let's consider following configuration
18
+ Aggregate repositories are part of ` prooph/event-sourcing ` however , bundle will no longer register repositories as a
19
+ services. You have to configure those by yourself. Let's consider following configuration:
20
20
21
21
``` yaml
22
22
prooph_event_store :
@@ -52,7 +52,7 @@ services:
52
52
app.event_store.pdo :
53
53
class : \PDO
54
54
55
- app.event_store.mysql .persistence_strategy :
55
+ app.event_store.postgres .persistence_strategy :
56
56
class : Prooph\EventStore\Pdo\PersistenceStrategy\PostgresSimpleStreamStrategy
57
57
` ` `
58
58
63
63
aggregate, so it can be injected into repository
64
64
2. define each repository as a service
65
65
66
- Your configuration should be transformed as follows
66
+ However, `AggregateRepository` requires such dependencies as `Prooph\EventSourcing\Aggregate\AggregateType`
67
+ and/or `Prooph\EventStore\StreamName`. It can be a bit overhead defining those as services as well. Since your
68
+ repository class is defined as a service already, you can
69
+ overwrite `Prooph\EventSourcing\Aggregate\AggregateRepository::__construct` like this :
70
+
71
+ ` ` ` php
72
+ <?php
73
+
74
+ declare(strict_types=1);
75
+
76
+ namespace App\I nfrastructure\P ersistence;
77
+
78
+ use App\D omain\M odel\S omeAggregate;
79
+ use Prooph\E ventSourcing\A ggregate\A ggregateRepository;
80
+ use Prooph\E ventSourcing\A ggregate\A ggregateType;
81
+ use Prooph\E ventSourcing\E ventStoreIntegration\A ggregateTranslator;
82
+ use Prooph\E ventStore\E ventStore;
83
+ use Prooph\E ventStore\S treamName;
84
+ use Prooph\S napshotStore\S napshotStore;
85
+
86
+ class SomeAggregateRepository extends AggregateRepository
87
+ {
88
+ public function __construct(EventStore $eventStore, SnapshotStore $snapshotStore)
89
+ {
90
+ parent::__construct(
91
+ $eventStore,
92
+ AggregateType::fromAggregateRootClass(SomeAggregate::class),
93
+ new AggregateTranslator(),
94
+ $snapshotStore,
95
+ new StreamName('some_aggregate_stream')
96
+ );
97
+ }
98
+ }
99
+ ` ` `
100
+
101
+ This will let you use autowiring without any additional configuration. Your configuration should look as follows :
67
102
68
103
` ` ` yaml
69
104
prooph_event_store:
@@ -81,39 +116,17 @@ prooph_event_store:
81
116
projection: App\I nfrastructure\P rojection\S omeProjection
82
117
83
118
services:
84
- Prooph\E ventSourcing\E ventStoreIntegration\A ggregateTranslator: ~
85
119
86
120
Prooph\E ventStore\E ventStore:
87
- class: 'Prooph\E ventStore\P do\P ostgresEventStore'
88
- arguments:
89
- - '@prooph_event_store.message_factory'
90
- - '@app.event_store.pdo'
91
- - '@app.event_store.persistence_strategy'
92
-
93
- app.some_aggregate.type:
94
- class: 'Prooph\E ventSourcing\A ggregate\A ggregateType'
95
- factory: [ 'Prooph\E ventSourcing\A ggregate\A ggregateType', 'fromAggregateRootClass' ]
96
- arguments:
97
- - 'App\D omain\M odel\S omeAggregate'
98
-
99
- app.some_aggregate.stream:
100
- class: 'Prooph\E ventStore\S treamName'
121
+ class: 'Prooph\E ventStore\P do\P ostgresEventStore'
101
122
arguments:
102
- - 'some_aggregate_stream'
103
-
104
- App\I nfrastructure\P ersistence\S omeAggregateRepository:
105
- arguments:
106
- $eventStore: '@prooph_event_store.default'
107
- $aggregateType: '@app.some_aggregate.type'
108
- $aggregateTranslator: Prooph\E ventSourcing\E ventStoreIntegration\A ggregateTranslator
109
- $streamName: '@app.some_aggregate.stream'
110
- $oneStreamPerAggregate: true
123
+ - '@prooph_event_store.message_factory'
124
+ - '@app.event_store.pdo'
125
+ - '@app.event_store.persistence_strategy'
111
126
112
127
app.event_store.pdo:
113
- class: \P DO
128
+ class: \P DO
114
129
115
- app.event_store.mysql .persistence_strategy:
130
+ app.event_store.postgres .persistence_strategy:
116
131
class: Prooph\E ventStore\P do\P ersistenceStrategy\P ostgresSimpleStreamStrategy
117
132
` ` `
118
-
119
- A bit overloading, but writing Event Sourcing component by yourself is quite easy (it takes few classes to work).
0 commit comments