Skip to content

Commit 6d7ee3e

Browse files
committed
- changing description of migration from 0.8.0
1 parent 67ac599 commit 6d7ee3e

File tree

1 file changed

+49
-36
lines changed

1 file changed

+49
-36
lines changed

doc/migrating_from_0.8.0.md

Lines changed: 49 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# Migrating from 0.8.0
22

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.
77

88
## Explicit installation of event sourcing component
99

@@ -15,8 +15,8 @@ $ composer install prooph/event-sourcing
1515

1616
## Explicit definition of aggregate repositories
1717

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:
2020

2121
```yaml
2222
prooph_event_store:
@@ -52,7 +52,7 @@ services:
5252
app.event_store.pdo:
5353
class: \PDO
5454

55-
app.event_store.mysql.persistence_strategy:
55+
app.event_store.postgres.persistence_strategy:
5656
class: Prooph\EventStore\Pdo\PersistenceStrategy\PostgresSimpleStreamStrategy
5757
```
5858
@@ -63,7 +63,42 @@ to
6363
aggregate, so it can be injected into repository
6464
2. define each repository as a service
6565

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\Infrastructure\Persistence;
77+
78+
use App\Domain\Model\SomeAggregate;
79+
use Prooph\EventSourcing\Aggregate\AggregateRepository;
80+
use Prooph\EventSourcing\Aggregate\AggregateType;
81+
use Prooph\EventSourcing\EventStoreIntegration\AggregateTranslator;
82+
use Prooph\EventStore\EventStore;
83+
use Prooph\EventStore\StreamName;
84+
use Prooph\SnapshotStore\SnapshotStore;
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:
67102

68103
```yaml
69104
prooph_event_store:
@@ -81,39 +116,17 @@ prooph_event_store:
81116
projection: App\Infrastructure\Projection\SomeProjection
82117
83118
services:
84-
Prooph\EventSourcing\EventStoreIntegration\AggregateTranslator: ~
85119
86120
Prooph\EventStore\EventStore:
87-
class: 'Prooph\EventStore\Pdo\PostgresEventStore'
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\EventSourcing\Aggregate\AggregateType'
95-
factory: [ 'Prooph\EventSourcing\Aggregate\AggregateType', 'fromAggregateRootClass' ]
96-
arguments:
97-
- 'App\Domain\Model\SomeAggregate'
98-
99-
app.some_aggregate.stream:
100-
class: 'Prooph\EventStore\StreamName'
121+
class: 'Prooph\EventStore\Pdo\PostgresEventStore'
101122
arguments:
102-
- 'some_aggregate_stream'
103-
104-
App\Infrastructure\Persistence\SomeAggregateRepository:
105-
arguments:
106-
$eventStore: '@prooph_event_store.default'
107-
$aggregateType: '@app.some_aggregate.type'
108-
$aggregateTranslator: Prooph\EventSourcing\EventStoreIntegration\AggregateTranslator
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'
111126
112127
app.event_store.pdo:
113-
class: \PDO
128+
class: \PDO
114129
115-
app.event_store.mysql.persistence_strategy:
130+
app.event_store.postgres.persistence_strategy:
116131
class: Prooph\EventStore\Pdo\PersistenceStrategy\PostgresSimpleStreamStrategy
117132
```
118-
119-
A bit overloading, but writing Event Sourcing component by yourself is quite easy (it takes few classes to work).

0 commit comments

Comments
 (0)