Skip to content

Commit e4c3081

Browse files
authored
Merge pull request #227 from dotkernel/issue-225
Refactored doctrine config
2 parents 39ecb9e + 9663b85 commit e4c3081

5 files changed

Lines changed: 11 additions & 43 deletions

File tree

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"require": {
3030
"php": "~8.2.0 || ~8.3.0",
3131
"ext-gettext": "*",
32-
"dotkernel/dot-annotated-services": "^4.1.3",
32+
"dotkernel/dot-annotated-services": "^4.1.7",
3333
"dotkernel/dot-cli": "^3.5.0",
3434
"dotkernel/dot-controller": "^3.4.3",
3535
"dotkernel/dot-data-fixtures": "^1.1.3",

config/autoload/doctrine.global.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Doctrine\ORM\EntityManager;
66
use Doctrine\ORM\EntityManagerInterface;
77
use Doctrine\Persistence\Mapping\Driver\MappingDriverChain;
8+
use Frontend\App\Resolver\EntityListenerResolver;
89
use Ramsey\Uuid\Doctrine\UuidBinaryOrderedTimeType;
910
use Ramsey\Uuid\Doctrine\UuidBinaryType;
1011
use Ramsey\Uuid\Doctrine\UuidType;
@@ -22,28 +23,33 @@
2223
],
2324
],
2425
'doctrine' => [
25-
'connection' => [
26+
'configuration' => [
27+
'orm_default' => [
28+
'entity_listener_resolver' => EntityListenerResolver::class,
29+
],
30+
],
31+
'connection' => [
2632
'orm_default' => [
2733
'doctrine_mapping_types' => [
2834
UuidBinaryType::NAME => 'binary',
2935
UuidBinaryOrderedTimeType::NAME => 'binary',
3036
],
3137
],
3238
],
33-
'driver' => [
39+
'driver' => [
3440
// default metadata driver, aggregates all other drivers into a single one.
3541
// Override `orm_default` only if you know what you're doing
3642
'orm_default' => [
3743
'class' => MappingDriverChain::class,
3844
'drivers' => [],
3945
],
4046
],
41-
'types' => [
47+
'types' => [
4248
UuidType::NAME => UuidType::class,
4349
UuidBinaryType::NAME => UuidBinaryType::class,
4450
UuidBinaryOrderedTimeType::NAME => UuidBinaryOrderedTimeType::class,
4551
],
46-
'fixtures' => getcwd() . '/data/doctrine/fixtures',
52+
'fixtures' => getcwd() . '/data/doctrine/fixtures',
4753
],
4854
'resultCacheLifetime' => 300,
4955
];

src/App/src/ConfigProvider.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ public function __invoke(): array
2323
{
2424
return [
2525
'dependencies' => $this->getDependencies(),
26-
'doctrine' => $this->getDoctrineConfig(),
2726
'templates' => $this->getTemplates(),
2827
];
2928
}
@@ -52,17 +51,6 @@ public function getDependencies(): array
5251
];
5352
}
5453

55-
public function getDoctrineConfig(): array
56-
{
57-
return [
58-
'configuration' => [
59-
'orm_default' => [
60-
'entity_listener_resolver' => EntityListenerResolver::class,
61-
],
62-
],
63-
];
64-
}
65-
6654
public function getTemplates(): array
6755
{
6856
return [

test/Unit/Admin/ConfigProviderTest.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,6 @@ public function testConfigHasDotForm(): void
4343
$this->assertArrayHasKey('form', $this->config);
4444
}
4545

46-
public function testConfigHasDoctrine(): void
47-
{
48-
$this->assertArrayHasKey('doctrine', $this->config);
49-
}
50-
5146
public function testDependenciesHasFactories(): void
5247
{
5348
$this->assertArrayHasKey('factories', $this->config['dependencies']);

test/Unit/App/ConfigProviderTest.php

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,6 @@ public function testConfigHasDependencies(): void
3232
$this->assertArrayHasKey('dependencies', $this->config);
3333
}
3434

35-
public function testConfigHasDoctrine(): void
36-
{
37-
$this->assertArrayHasKey('doctrine', $this->config);
38-
}
39-
4035
public function testConfigHasTemplates(): void
4136
{
4237
$this->assertArrayHasKey('templates', $this->config);
@@ -76,22 +71,6 @@ public function testDependenciesHasAliases(): void
7671
$this->assertArrayHasKey(EntityManagerInterface::class, $this->config['dependencies']['aliases']);
7772
}
7873

79-
public function testGetDoctrineConfig(): void
80-
{
81-
$this->assertArrayHasKey('configuration', $this->config['doctrine']);
82-
$this->assertIsArray($this->config['doctrine']['configuration']);
83-
$this->assertArrayHasKey('orm_default', $this->config['doctrine']['configuration']);
84-
$this->assertIsArray($this->config['doctrine']['configuration']['orm_default']);
85-
$this->assertArrayHasKey(
86-
'entity_listener_resolver',
87-
$this->config['doctrine']['configuration']['orm_default']
88-
);
89-
$this->assertSame(
90-
EntityListenerResolver::class,
91-
$this->config['doctrine']['configuration']['orm_default']['entity_listener_resolver']
92-
);
93-
}
94-
9574
public function testGetTemplates(): void
9675
{
9776
$this->assertArrayHasKey('paths', $this->config['templates']);

0 commit comments

Comments
 (0)