Skip to content

Commit 97d7f11

Browse files
rixafyf3l1x
authored andcommitted
Improve configuration structure
1 parent 61ef841 commit 97d7f11

15 files changed

+41
-44
lines changed

.docs/README.md

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ nettrine.orm:
5050
connection: default
5151
mapping:
5252
App:
53-
type: attributes
54-
dirs: [%appDir%/Database]
53+
directories: [%appDir%/Database]
5554
namespace: App/Database
5655
```
5756

@@ -91,7 +90,7 @@ nettrine.orm:
9190
mapping:
9291
<name>:
9392
type: <attributes|xml>
94-
dirs: <string[]>
93+
directories: <string[]>
9594
namespace: <string>
9695
9796
defaultCache: <class-string|service>
@@ -133,8 +132,7 @@ nettrine.orm:
133132
connection: default
134133
mapping:
135134
App:
136-
type: attributes
137-
dirs: [%appDir%/Database]
135+
directories: [%appDir%/Database]
138136
namespace: App\Database
139137
```
140138

@@ -320,8 +318,7 @@ nettrine.orm:
320318
connection: default
321319
mapping:
322320
App:
323-
type: attributes
324-
dirs: [%appDir%/Database]
321+
directories: [%appDir%/Database]
325322
namespace: App\Database
326323
```
327324

@@ -348,7 +345,7 @@ The XML mapping driver enables you to provide the ORM metadata in form of XML do
348345
</doctrine-mapping>
349346
```
350347

351-
Configuration for attribute mapping looks like this:
348+
Configuration for XML mapping looks like this:
352349

353350
```neon
354351
nettrine.orm:
@@ -358,7 +355,7 @@ nettrine.orm:
358355
mapping:
359356
App:
360357
type: xml
361-
dirs: [%appDir%/Database]
358+
directories: [%appDir%/Database]
362359
namespace: App\Database
363360
```
364361

src/DI/OrmExtension.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
* repositoryFactory: string|Statement|null,
4242
* defaultQueryHints: array<string, mixed>,
4343
* filters: array<string, object{class: string, enabled: bool}>,
44-
* mapping: array<string, object{type: 'attributes'|'xml', dirs: string[], namespace: string}>,
44+
* mapping: array<string, object{type: 'attributes'|'xml', directories: string[], namespace: string}>,
4545
* defaultCache: string|Statement|null,
4646
* queryCache: string|Statement|null,
4747
* resultCache: string|Statement|null,
@@ -123,8 +123,8 @@ public function getConfigSchema(): Schema
123123
),
124124
'mapping' => Expect::arrayOf(
125125
Expect::structure([
126-
'type' => Expect::anyOf('attributes', 'xml')->required(),
127-
'dirs' => Expect::listOf(Expect::string())->min(1)->required(),
126+
'type' => Expect::anyOf('attributes', 'xml')->default('attributes'),
127+
'directories' => Expect::listOf(Expect::string())->min(1)->required(),
128128
'namespace' => Expect::string()->required(),
129129
]),
130130
Expect::string()

src/DI/Pass/ManagerPass.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,12 +267,12 @@ public function loadManagerConfiguration(string $managerName, mixed $managerConf
267267
foreach ($managerConfig->mapping as $mapping) {
268268
if ($mapping->type === 'attributes') {
269269
$mappingDriver->addSetup('addDriver', [
270-
new Statement(AttributeDriver::class, [array_values($mapping->dirs)]),
270+
new Statement(AttributeDriver::class, [array_values($mapping->directories)]),
271271
$mapping->namespace,
272272
]);
273273
} elseif ($mapping->type === 'xml') {
274274
$mappingDriver->addSetup('addDriver', [
275-
new Statement(SimplifiedXmlDriver::class, [array_combine($mapping->dirs, array_fill(0, count($mapping->dirs), $mapping->namespace))]),
275+
new Statement(SimplifiedXmlDriver::class, [array_combine($mapping->directories, array_fill(0, count($mapping->directories), $mapping->namespace))]),
276276
$mapping->namespace,
277277
]);
278278
} else {

tests/Cases/DI/Helper/MappingHelper.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ Toolkit::test(function (): void {
6262
mapping:
6363
App:
6464
type: attributes
65-
dirs: [%fixturesDir%/Entity]
65+
directories: [%fixturesDir%/Entity]
6666
namespace: Tests\Mocks
6767
NEON
6868
));

tests/Cases/DI/OrmExtension.cache.phpt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Toolkit::test(function (): void {
4141
mapping:
4242
App:
4343
type: attributes
44-
dirs: [app/Database]
44+
directories: [app/Database]
4545
namespace: App\Database
4646
NEON
4747
));
@@ -90,7 +90,7 @@ Toolkit::test(function (): void {
9090
mapping:
9191
App:
9292
type: attributes
93-
dirs: [app/Database]
93+
directories: [app/Database]
9494
namespace: App\Database
9595
NEON
9696
));
@@ -137,7 +137,7 @@ Toolkit::test(function (): void {
137137
mapping:
138138
App:
139139
type: attributes
140-
dirs: [app/Database]
140+
directories: [app/Database]
141141
namespace: App\Database
142142
143143
services:
@@ -184,7 +184,7 @@ Toolkit::test(function (): void {
184184
mapping:
185185
App:
186186
type: attributes
187-
dirs: [app/Database]
187+
directories: [app/Database]
188188
namespace: App\Database
189189
NEON
190190
));
@@ -238,7 +238,7 @@ Toolkit::test(function (): void {
238238
mapping:
239239
App:
240240
type: attributes
241-
dirs: [app/Database]
241+
directories: [app/Database]
242242
namespace: App\Database
243243
244244
services:
@@ -289,7 +289,7 @@ Toolkit::test(function (): void {
289289
mapping:
290290
App:
291291
type: attributes
292-
dirs: [app/Database]
292+
directories: [app/Database]
293293
namespace: App\Database
294294
NEON
295295
));

tests/Cases/DI/OrmExtension.configuration.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Toolkit::test(function (): void {
4242
mapping:
4343
App:
4444
type: attributes
45-
dirs: [%fixturesDir%/Entity]
45+
directories: [%fixturesDir%/Entity]
4646
namespace: Tests\Mocks\Entity
4747
NEON
4848
));

tests/Cases/DI/OrmExtension.entityManager.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Toolkit::test(function (): void {
4141
mapping:
4242
App:
4343
type: attributes
44-
dirs: [app/Database]
44+
directories: [app/Database]
4545
namespace: App\Database
4646
NEON
4747
));
@@ -81,7 +81,7 @@ Toolkit::test(function (): void {
8181
mapping:
8282
App:
8383
type: attributes
84-
dirs: [app/Database]
84+
directories: [app/Database]
8585
namespace: App\Database
8686
NEON
8787
));

tests/Cases/DI/OrmExtension.events.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Toolkit::test(function (): void {
4242
mapping:
4343
App:
4444
type: attributes
45-
dirs: [app/Database]
45+
directories: [app/Database]
4646
namespace: App\Database
4747
NEON
4848
));
@@ -82,7 +82,7 @@ Toolkit::test(function (): void {
8282
mapping:
8383
App:
8484
type: attributes
85-
dirs: [app/Database]
85+
directories: [app/Database]
8686
namespace: App\Database
8787
8888
services:

tests/Cases/DI/OrmExtension.filters.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Toolkit::test(function (): void {
4545
mapping:
4646
App:
4747
type: attributes
48-
dirs: [app/Database]
48+
directories: [app/Database]
4949
namespace: App\Database
5050
NEON
5151
));

tests/Cases/DI/OrmExtension.mapping.phpt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Toolkit::test(function (): void {
4444
mapping:
4545
App:
4646
type: attributes
47-
dirs: [%fixturesDir%/Entity, %fixturesDir%/../Toolkit]
47+
directories: [%fixturesDir%/Entity, %fixturesDir%/../Toolkit]
4848
namespace: Tests\Fixtures\Dummy
4949
NEON
5050
));
@@ -91,7 +91,7 @@ Toolkit::test(function (): void {
9191
mapping:
9292
App:
9393
type: xml
94-
dirs: [%fixturesDir%/Entity, %fixturesDir%/../Toolkit]
94+
directories: [%fixturesDir%/Entity, %fixturesDir%/../Toolkit]
9595
namespace: Tests\Mocks\Dummy
9696
NEON
9797
));
@@ -138,11 +138,11 @@ Toolkit::test(function (): void {
138138
mapping:
139139
App:
140140
type: attributes
141-
dirs: [%fixturesDir%/Entity, %fixturesDir%/../Toolkit]
141+
directories: [%fixturesDir%/Entity, %fixturesDir%/../Toolkit]
142142
namespace: Tests\Mocks\Entity
143143
AppModule:
144144
type: xml
145-
dirs: [%fixturesDir%/Entity, %fixturesDir%/../Toolkit]
145+
directories: [%fixturesDir%/Entity, %fixturesDir%/../Toolkit]
146146
namespace: App\Module
147147
NEON
148148
));

0 commit comments

Comments
 (0)