Skip to content

Commit a98d381

Browse files
committed
psr-container-doctrine 5.2.1 support and refactoring modules configuration
Signed-off-by: Claudiu Pintiuta <claudiupintiuta@gmail.com>
1 parent 69699c9 commit a98d381

5 files changed

Lines changed: 76 additions & 25 deletions

File tree

composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,7 @@
7777
"mezzio/mezzio-problem-details": "^1.13.1",
7878
"mezzio/mezzio-twigrenderer": "^2.15.0",
7979
"ramsey/uuid-doctrine": "^2.1.0",
80-
"roave/psr-container-doctrine": "^5.1.0",
81-
"doctrine/orm": "^3.2",
80+
"roave/psr-container-doctrine": "^5.2.1",
8281
"symfony/filesystem": "^7.0.3"
8382
},
8483
"require-dev": {

config/autoload/doctrine.global.php

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,27 +24,8 @@
2424
'driver' => [
2525
'orm_default' => [
2626
'class' => MappingDriverChain::class,
27-
'drivers' => [
28-
'Api\\User\\Entity' => 'UserEntities',
29-
'Api\\Admin\\Entity' => 'AdminEntities',
30-
'Api\\App\Entity' => 'AppEntities',
31-
],
32-
],
33-
'AdminEntities' => [
34-
'class' => AttributeDriver::class,
35-
'cache' => 'array',
36-
'paths' => __DIR__ . '/../../src/Admin/src/Entity',
37-
],
38-
'UserEntities' => [
39-
'class' => AttributeDriver::class,
40-
'cache' => 'array',
41-
'paths' => __DIR__ . '/../../src/User/src/Entity',
42-
],
43-
'AppEntities' => [
44-
'class' => AttributeDriver::class,
45-
'cache' => 'array',
46-
'paths' => __DIR__ . '/../../src/App/src/Entity',
47-
],
27+
'drivers' => [],
28+
]
4829
],
4930
'types' => [
5031
UuidType::NAME => UuidType::class,
@@ -59,6 +40,7 @@
5940
'metadata_cache' => 'filesystem',
6041
'query_cache' => 'filesystem',
6142
'hydration_cache' => 'array',
43+
"typed_field_mapper" => null,
6244
'second_level_cache' => [
6345
'enabled' => true,
6446
'default_lifetime' => 3600,

src/Admin/src/ConfigProvider.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@
2020
use Api\Admin\Service\AdminService;
2121
use Api\Admin\Service\AdminServiceInterface;
2222
use Api\App\ConfigProvider as AppConfigProvider;
23+
use Doctrine\ORM\Mapping\Driver\AttributeDriver;
2324
use Dot\DependencyInjection\Factory\AttributedRepositoryFactory;
2425
use Dot\DependencyInjection\Factory\AttributedServiceFactory;
26+
use Mezzio\Application;
2527
use Mezzio\Hal\Metadata\MetadataMap;
2628

2729
class ConfigProvider
@@ -30,13 +32,19 @@ public function __invoke(): array
3032
{
3133
return [
3234
'dependencies' => $this->getDependencies(),
35+
'doctrine' => $this->getDoctrineConfig(),
3336
MetadataMap::class => $this->getHalConfig(),
3437
];
3538
}
3639

3740
public function getDependencies(): array
3841
{
3942
return [
43+
'delegators' => [
44+
Application::class => [
45+
RoutesDelegator::class
46+
]
47+
],
4048
'factories' => [
4149
AdminHandler::class => AttributedServiceFactory::class,
4250
AdminAccountHandler::class => AttributedServiceFactory::class,
@@ -54,6 +62,24 @@ public function getDependencies(): array
5462
];
5563
}
5664

65+
private function getDoctrineConfig(): array
66+
{
67+
return [
68+
'driver' => [
69+
'orm_default' => [
70+
'drivers' => [
71+
'Api\Admin\Entity' => 'AdminEntities'
72+
],
73+
],
74+
'AdminEntities' => [
75+
'class' => AttributeDriver::class,
76+
'cache' => 'array',
77+
'paths' => __DIR__ . '/Entity',
78+
],
79+
],
80+
];
81+
}
82+
5783
public function getHalConfig(): array
5884
{
5985
return [

src/App/src/ConfigProvider.php

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
use Api\App\Service\ErrorReportServiceInterface;
2323
use Doctrine\ORM\EntityManager;
2424
use Doctrine\ORM\EntityManagerInterface;
25+
use Doctrine\ORM\Mapping\Driver\AttributeDriver;
2526
use Dot\DependencyInjection\Factory\AttributedServiceFactory;
2627
use Dot\Mail\Factory\MailOptionsAbstractFactory;
2728
use Dot\Mail\Factory\MailServiceAbstractFactory;
@@ -47,6 +48,7 @@ public function __invoke(): array
4748
{
4849
return [
4950
'dependencies' => $this->getDependencies(),
51+
'doctrine' => $this->getDoctrineConfig(),
5052
MetadataMap::class => $this->getHalConfig(),
5153
];
5254
}
@@ -57,8 +59,6 @@ public function getDependencies(): array
5759
'delegators' => [
5860
Application::class => [
5961
RoutesDelegator::class,
60-
\Api\Admin\RoutesDelegator::class,
61-
\Api\User\RoutesDelegator::class,
6262
],
6363
],
6464
'factories' => [
@@ -91,6 +91,24 @@ public function getDependencies(): array
9191
];
9292
}
9393

94+
private function getDoctrineConfig(): array
95+
{
96+
return [
97+
'driver' => [
98+
'orm_default' => [
99+
'drivers' => [
100+
'Api\App\Entity' => 'AppEntities'
101+
],
102+
],
103+
'AppEntities' => [
104+
'class' => AttributeDriver::class,
105+
'cache' => 'array',
106+
'paths' => __DIR__ . '/Entity',
107+
],
108+
],
109+
];
110+
}
111+
94112
public function getHalConfig(): array
95113
{
96114
return [];

src/User/src/ConfigProvider.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@
3131
use Api\User\Service\UserRoleServiceInterface;
3232
use Api\User\Service\UserService;
3333
use Api\User\Service\UserServiceInterface;
34+
use Doctrine\ORM\Mapping\Driver\AttributeDriver;
3435
use Dot\DependencyInjection\Factory\AttributedRepositoryFactory;
3536
use Dot\DependencyInjection\Factory\AttributedServiceFactory;
37+
use Mezzio\Application;
3638
use Mezzio\Hal\Metadata\MetadataMap;
3739

3840
class ConfigProvider
@@ -41,6 +43,7 @@ public function __invoke(): array
4143
{
4244
return [
4345
'dependencies' => $this->getDependencies(),
46+
'doctrine' => $this->getDoctrineConfig(),
4447
MetadataMap::class => $this->getHalConfig(),
4548
'templates' => $this->getTemplates(),
4649
];
@@ -49,6 +52,11 @@ public function __invoke(): array
4952
public function getDependencies(): array
5053
{
5154
return [
55+
'delegators' => [
56+
Application::class => [
57+
RoutesDelegator::class,
58+
]
59+
],
5260
'factories' => [
5361
AccountActivateHandler::class => AttributedServiceFactory::class,
5462
AccountAvatarHandler::class => AttributedServiceFactory::class,
@@ -77,6 +85,24 @@ public function getDependencies(): array
7785
];
7886
}
7987

88+
private function getDoctrineConfig(): array
89+
{
90+
return [
91+
'driver' => [
92+
'orm_default' => [
93+
'drivers' => [
94+
'Api\User\Entity' => 'UserEntities'
95+
],
96+
],
97+
'UserEntities' => [
98+
'class' => AttributeDriver::class,
99+
'cache' => 'array',
100+
'paths' => __DIR__ . '/Entity',
101+
],
102+
],
103+
];
104+
}
105+
80106
public function getHalConfig(): array
81107
{
82108
return [

0 commit comments

Comments
 (0)