Skip to content

Commit

Permalink
Improve configuration structure
Browse files Browse the repository at this point in the history
  • Loading branch information
Rixafy committed Dec 31, 2024
1 parent 2941bca commit e700173
Show file tree
Hide file tree
Showing 14 changed files with 35 additions and 35 deletions.
6 changes: 3 additions & 3 deletions src/DI/OrmExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
* repositoryFactory: string|Statement|null,
* defaultQueryHints: array<string, mixed>,
* filters: array<string, object{class: string, enabled: bool}>,
* mapping: array<string, object{type: 'attributes'|'xml', dirs: string[], namespace: string}>,
* mapping: array<string, object{type: 'attributes'|'xml', directories: string[], namespace: string}>,
* defaultCache: string|Statement|null,
* queryCache: string|Statement|null,
* resultCache: string|Statement|null,
Expand Down Expand Up @@ -123,8 +123,8 @@ public function getConfigSchema(): Schema
),
'mapping' => Expect::arrayOf(
Expect::structure([
'type' => Expect::anyOf('attributes', 'xml')->required(),
'dirs' => Expect::listOf(Expect::string())->min(1)->required(),
'type' => Expect::anyOf('attributes', 'xml')->default('attributes'),
'directories' => Expect::listOf(Expect::string())->min(1)->required(),
'namespace' => Expect::string()->required(),
]),
Expect::string()
Expand Down
4 changes: 2 additions & 2 deletions src/DI/Pass/ManagerPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,12 +267,12 @@ public function loadManagerConfiguration(string $managerName, mixed $managerConf
foreach ($managerConfig->mapping as $mapping) {
if ($mapping->type === 'attributes') {
$mappingDriver->addSetup('addDriver', [
new Statement(AttributeDriver::class, [array_values($mapping->dirs)]),
new Statement(AttributeDriver::class, [array_values($mapping->directories)]),
$mapping->namespace,
]);
} elseif ($mapping->type === 'xml') {
$mappingDriver->addSetup('addDriver', [
new Statement(SimplifiedXmlDriver::class, [array_combine($mapping->dirs, array_fill(0, count($mapping->dirs), $mapping->namespace))]),
new Statement(SimplifiedXmlDriver::class, [array_combine($mapping->directories, array_fill(0, count($mapping->directories), $mapping->namespace))]),
$mapping->namespace,
]);
} else {
Expand Down
2 changes: 1 addition & 1 deletion tests/Cases/DI/Helper/MappingHelper.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Toolkit::test(function (): void {
mapping:
App:
type: attributes
dirs: [%fixturesDir%/Entity]
directories: [%fixturesDir%/Entity]
namespace: Tests\Mocks
NEON
));
Expand Down
12 changes: 6 additions & 6 deletions tests/Cases/DI/OrmExtension.cache.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Toolkit::test(function (): void {
mapping:
App:
type: attributes
dirs: [app/Database]
directories: [app/Database]
namespace: App\Database
NEON
));
Expand Down Expand Up @@ -90,7 +90,7 @@ Toolkit::test(function (): void {
mapping:
App:
type: attributes
dirs: [app/Database]
directories: [app/Database]
namespace: App\Database
NEON
));
Expand Down Expand Up @@ -137,7 +137,7 @@ Toolkit::test(function (): void {
mapping:
App:
type: attributes
dirs: [app/Database]
directories: [app/Database]
namespace: App\Database
services:
Expand Down Expand Up @@ -184,7 +184,7 @@ Toolkit::test(function (): void {
mapping:
App:
type: attributes
dirs: [app/Database]
directories: [app/Database]
namespace: App\Database
NEON
));
Expand Down Expand Up @@ -238,7 +238,7 @@ Toolkit::test(function (): void {
mapping:
App:
type: attributes
dirs: [app/Database]
directories: [app/Database]
namespace: App\Database
services:
Expand Down Expand Up @@ -289,7 +289,7 @@ Toolkit::test(function (): void {
mapping:
App:
type: attributes
dirs: [app/Database]
directories: [app/Database]
namespace: App\Database
NEON
));
Expand Down
2 changes: 1 addition & 1 deletion tests/Cases/DI/OrmExtension.configuration.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Toolkit::test(function (): void {
mapping:
App:
type: attributes
dirs: [%fixturesDir%/Entity]
directories: [%fixturesDir%/Entity]
namespace: Tests\Mocks\Entity
NEON
));
Expand Down
4 changes: 2 additions & 2 deletions tests/Cases/DI/OrmExtension.entityManager.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Toolkit::test(function (): void {
mapping:
App:
type: attributes
dirs: [app/Database]
directories: [app/Database]
namespace: App\Database
NEON
));
Expand Down Expand Up @@ -81,7 +81,7 @@ Toolkit::test(function (): void {
mapping:
App:
type: attributes
dirs: [app/Database]
directories: [app/Database]
namespace: App\Database
NEON
));
Expand Down
4 changes: 2 additions & 2 deletions tests/Cases/DI/OrmExtension.events.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Toolkit::test(function (): void {
mapping:
App:
type: attributes
dirs: [app/Database]
directories: [app/Database]
namespace: App\Database
NEON
));
Expand Down Expand Up @@ -82,7 +82,7 @@ Toolkit::test(function (): void {
mapping:
App:
type: attributes
dirs: [app/Database]
directories: [app/Database]
namespace: App\Database
services:
Expand Down
2 changes: 1 addition & 1 deletion tests/Cases/DI/OrmExtension.filters.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Toolkit::test(function (): void {
mapping:
App:
type: attributes
dirs: [app/Database]
directories: [app/Database]
namespace: App\Database
NEON
));
Expand Down
8 changes: 4 additions & 4 deletions tests/Cases/DI/OrmExtension.mapping.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Toolkit::test(function (): void {
mapping:
App:
type: attributes
dirs: [%fixturesDir%/Entity, %fixturesDir%/../Toolkit]
directories: [%fixturesDir%/Entity, %fixturesDir%/../Toolkit]
namespace: Tests\Fixtures\Dummy
NEON
));
Expand Down Expand Up @@ -91,7 +91,7 @@ Toolkit::test(function (): void {
mapping:
App:
type: xml
dirs: [%fixturesDir%/Entity, %fixturesDir%/../Toolkit]
directories: [%fixturesDir%/Entity, %fixturesDir%/../Toolkit]
namespace: Tests\Mocks\Dummy
NEON
));
Expand Down Expand Up @@ -138,11 +138,11 @@ Toolkit::test(function (): void {
mapping:
App:
type: attributes
dirs: [%fixturesDir%/Entity, %fixturesDir%/../Toolkit]
directories: [%fixturesDir%/Entity, %fixturesDir%/../Toolkit]
namespace: Tests\Mocks\Entity
AppModule:
type: xml
dirs: [%fixturesDir%/Entity, %fixturesDir%/../Toolkit]
directories: [%fixturesDir%/Entity, %fixturesDir%/../Toolkit]
namespace: App\Module
NEON
));
Expand Down
2 changes: 1 addition & 1 deletion tests/Cases/DI/OrmExtension.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Toolkit::test(function (): void {
mapping:
App:
type: attributes
dirs: [app/Database]
directories: [app/Database]
namespace: App\Database
NEON
));
Expand Down
6 changes: 3 additions & 3 deletions tests/Cases/DI/OrmExtension.proxy.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Toolkit::test(function (): void {
mapping:
App:
type: attributes
dirs: [app/Database]
directories: [app/Database]
namespace: App\Database
NEON
));
Expand Down Expand Up @@ -81,7 +81,7 @@ Toolkit::test(function (): void {
mapping:
App:
type: attributes
dirs: [app/Database]
directories: [app/Database]
namespace: App\Database
NEON
));
Expand Down Expand Up @@ -122,7 +122,7 @@ Toolkit::test(function (): void {
mapping:
App:
type: attributes
dirs: [app/Database]
directories: [app/Database]
namespace: App\Database
NEON
));
Expand Down
2 changes: 1 addition & 1 deletion tests/Cases/DI/OrmExtension.resolveTargetEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
mapping:
App:
type: attributes
dirs: [%fixturesDir%/Entity]
directories: [%fixturesDir%/Entity]
namespace: Tests\Mocks\Entity
NEON
));
Expand Down
8 changes: 4 additions & 4 deletions tests/Cases/DI/OrmExtension.services.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Toolkit::test(function (): void {
mapping:
App:
type: attributes
dirs: [app/Database]
directories: [app/Database]
namespace: App\Database
NEON
));
Expand Down Expand Up @@ -92,7 +92,7 @@ Toolkit::test(function (): void {
mapping:
App:
type: attributes
dirs: [app/Database]
directories: [app/Database]
namespace: App\Database
services:
entityListenerResolver: Doctrine\ORM\Mapping\DefaultEntityListenerResolver()
Expand Down Expand Up @@ -144,7 +144,7 @@ Toolkit::test(function (): void {
mapping:
App:
type: attributes
dirs: [app/Database]
directories: [app/Database]
namespace: App\Database
NEON
));
Expand Down Expand Up @@ -191,7 +191,7 @@ Toolkit::test(function (): void {
mapping:
App:
type: attributes
dirs: [app/Database]
directories: [app/Database]
namespace: App\Database
NEON
));
Expand Down
8 changes: 4 additions & 4 deletions tests/Cases/ManagerRegistry.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ Toolkit::test(function (): void {
mapping:
App:
type: attributes
dirs: [app/Database]
directories: [app/Database]
namespace: App\Database
second:
connection: second
mapping:
App:
type: attributes
dirs: [app/Database]
directories: [app/Database]
namespace: App\Database
NEON
));
Expand Down Expand Up @@ -98,15 +98,15 @@ Toolkit::test(function (): void {
mapping:
App:
type: attributes
dirs: [app/Database]
directories: [app/Database]
namespace: App\Database
second:
connection: second
entityManagerDecoratorClass: Tests\Mocks\DummyEntityManagerDecorator
mapping:
App:
type: attributes
dirs: [app/Database]
directories: [app/Database]
namespace: App\Database
NEON
));
Expand Down

0 comments on commit e700173

Please sign in to comment.