Skip to content

Commit 0b207db

Browse files
dgafkagitbook-bot
authored andcommitted
GITBOOK-834: No subject
1 parent 6d86d16 commit 0b207db

File tree

3 files changed

+56
-12
lines changed

3 files changed

+56
-12
lines changed

modelling/command-handling/repository.md

+10
Original file line numberDiff line numberDiff line change
@@ -181,3 +181,13 @@ To enable it read in [Dbal Module Section](../../modules/dbal-support.md#documen
181181
### - Event Sourcing Repository
182182

183183
Ecotone provides inbuilt Event Sourcing Repository, which will set up Event Store and Event Streams. To enable it read [Event Sourcing Section](../event-sourcing/).
184+
185+
## Using Multiple Repositories
186+
187+
By default Ecotone when we have only one Standard and Event Sourcing Repository registered, Ecotone will use them for our Aggregate by default. \
188+
This comes from simplification, as if there is only one Repository of given type, then there is nothing else to be choose from. \
189+
\
190+
However, if we register multiple Repositories, then we need to take over the process and tell which Repository will be used for which Aggregate. 
191+
192+
* In case of [Custom Repositories](repository.md#set-up-your-own-implementation) we do it using **canHandle** method.
193+
* In case of inbuilt Repositories, we should follow configuration section for given type

modules/dbal-support.md

+28-12
Original file line numberDiff line numberDiff line change
@@ -94,25 +94,41 @@ Every document is stored inside the "`ecotone_document_store`" table. 
9494
You may enable support for [storing standard aggregates](dbal-support.md#standard-aggregate-repository).
9595

9696
```php
97-
#[ServiceContext]
98-
public function getDbalConfiguration(): DbalConfiguration
99-
{
100-
return DbalConfiguration::createWithDefaults()
101-
->withDocumentStore(enableDocumentStoreAggregateRepository: true);
102-
}
97+
#[ServiceContext]
98+
public function getDbalConfiguration(): DbalConfiguration
99+
{
100+
return DbalConfiguration::createWithDefaults()
101+
->withDocumentStore(enableDocumentStoreAggregateRepository: true);
102+
}
103103
```
104104

105105
### In Memory Document Store 
106106

107107
For testing purposes you may want to enable `In Memory implementation`.
108108

109109
```php
110-
#[ServiceContext]
111-
public function configuration()
112-
{
113-
return DbalConfiguration::createWithDefaults()
114-
->withDocumentStore(inMemoryDocumentStore: true);
115-
}
110+
#[ServiceContext]
111+
public function configuration()
112+
{
113+
return DbalConfiguration::createWithDefaults()
114+
->withDocumentStore(inMemoryDocumentStore: true);
115+
}
116+
```
117+
118+
### Document Store related Aggregates
119+
120+
To enable specific Aggregates for Document Store Repository:
121+
122+
```php
123+
#[ServiceContext]
124+
public function getDbalConfiguration(): DbalConfiguration
125+
{
126+
return DbalConfiguration::createWithDefaults()
127+
->withDocumentStore(
128+
enableDocumentStoreAggregateRepository: true,
129+
documentStoreRelatedAggregates: [Ticket::class]
130+
);
131+
}
116132
```
117133

118134
### Table initialization

modules/symfony/doctrine-orm.md

+18
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,24 @@ class Person
117117
private ?int $personId = null;
118118
```
119119

120+
### Enable Repository for given Aggregates
121+
122+
To enable Doctrine ORM for given set of Aggregates use DbalConfiguration:
123+
124+
```php
125+
class EcotoneConfiguration
126+
{
127+
#[ServiceContext]
128+
public function getDbalConfiguration(): DbalConfiguration
129+
{
130+
return DbalConfiguration::createWithDefaults()
131+
->withDoctrineORMRepositories(
132+
true,
133+
[Article::class]
134+
);
135+
}
136+
```
137+
120138
### Demo
121139

122140
Read more about integration in [following blog post](https://blog.ecotone.tech/build-symfony-application-with-ease-using-ecotone/).

0 commit comments

Comments
 (0)